ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • import
    Study/JavaScript 2020. 5. 14. 17:40

    import

    ES6 module syntax also introduces the import keyword for importing objects. In our order.js example, we import an object like this:

    import Menu from './menu';

    1. The import keyword begins the statement.
    2. The keyword Menu here specifies the name of the variable to store the default export in.
    3. from specifies where to load the module from.
    4. './menu' is the name of the module to load. When dealing with local files, it specifically refers to the name of the file without the extension of the file.

    We can then continue using the Menu module in the order.js file.

     


    import Airplane from './airplane';
    
    function displayFuelCapacity() {
      Airplane.availableAirplanes.forEach(function(element){
      console.log('Fuel Capacity of ' + element.name + ': ' + element.fuelCapacity);
      });
    }
    
    displayFuelCapacity();

    'Study > JavaScript' 카테고리의 다른 글

    Export Named Exports  (0) 2020.05.14
    Named Exports  (0) 2020.05.14
    export default  (0) 2020.05.14
    module.exports II  (0) 2020.05.14
    require()  (0) 2020.05.14

    댓글

Designed by Tistory.