- Hands-On Machine Learning with JavaScript
- Burak Kanber
- 120字
- 2021-06-25 21:38:18
Module imports
ES6 also defines a module import and export interface. With the older CommonJS approach, modules are exported using the modules.export construct, and modules are imported with the require(filename) function. The ES6 approach looks a little different. In one file, define and export a class, as shown in the following code:
Class Automobile {
…
}
export default Automobile
And in another file, import the class, as shown in the following code:
import Automobile from ‘./classes/automobile.js’;
const myCar = new Automobile();
At present, Babel compiles ES6 modules to the same format as CommonJS modules, so you can use either the ES6 modules syntax or the CommonJS modules syntax if you’re using Babel.
推薦閱讀
- 大數據導論:思維、技術與應用
- 電力自動化實用技術問答
- Python Artificial Intelligence Projects for Beginners
- VMware Performance and Capacity Management(Second Edition)
- STM32G4入門與電機控制實戰:基于X-CUBE-MCSDK的無刷直流電機與永磁同步電機控制實現
- CentOS 8 Essentials
- Hybrid Cloud for Architects
- Apache Superset Quick Start Guide
- Practical Big Data Analytics
- Working with Linux:Quick Hacks for the Command Line
- ESP8266 Robotics Projects
- 手機游戲策劃設計
- 三菱FX/Q系列PLC工程實例詳解
- Web編程基礎
- PowerMill 2020五軸數控加工編程應用實例