- 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.
推薦閱讀
- 基于C語言的程序設計
- 集成架構中型系統
- Dreamweaver CS3+Flash CS3+Fireworks CS3創意網站構建實例詳解
- Mastercam 2017數控加工自動編程經典實例(第4版)
- 手把手教你玩轉RPA:基于UiPath和Blue Prism
- 輕松學Java
- RPA:流程自動化引領數字勞動力革命
- 大數據處理平臺
- 網絡組建與互聯
- Azure PowerShell Quick Start Guide
- 嵌入式操作系統原理及應用
- R Machine Learning Projects
- IBM? SmartCloud? Essentials
- Artificial Intelligence By Example
- TensorFlow Deep Learning Projects