- 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.
推薦閱讀
- 大數(shù)據(jù)技術(shù)與應(yīng)用基礎(chǔ)
- Instant Raspberry Pi Gaming
- Project 2007項(xiàng)目管理實(shí)用詳解
- Verilog HDL數(shù)字系統(tǒng)設(shè)計(jì)入門與應(yīng)用實(shí)例
- 網(wǎng)頁(yè)編程技術(shù)
- 手把手教你玩轉(zhuǎn)RPA:基于UiPath和Blue Prism
- MCSA Windows Server 2016 Certification Guide:Exam 70-741
- Mastering Elastic Stack
- PHP開(kāi)發(fā)手冊(cè)
- 小型電動(dòng)機(jī)實(shí)用設(shè)計(jì)手冊(cè)
- 大數(shù)據(jù)挑戰(zhàn)與NoSQL數(shù)據(jù)庫(kù)技術(shù)
- 3D Printing for Architects with MakerBot
- LAMP網(wǎng)站開(kāi)發(fā)黃金組合Linux+Apache+MySQL+PHP
- Microsoft System Center Confi guration Manager
- 貫通Hibernate開(kāi)發(fā)