mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-24 18:32:22 +00:00
edit module
This commit is contained in:
parent
61d7165df9
commit
61d2f36c9c
@ -484,4 +484,4 @@ fs.writeFileSync('out.js.map', result.sourceMap);
|
|||||||
|
|
||||||
ECMAScript当前的所有提案,可以在TC39的官方网站[Github.com/tc39/ecma262](https://github.com/tc39/ecma262)查看。
|
ECMAScript当前的所有提案,可以在TC39的官方网站[Github.com/tc39/ecma262](https://github.com/tc39/ecma262)查看。
|
||||||
|
|
||||||
Babel转码器可以通过安装和使用插件来使用各个stage的语言。
|
Babel转码器可以通过安装和使用插件来使用各个stage的语法。
|
||||||
|
@ -26,7 +26,7 @@ ES6模块不是对象,而是通过`export`命令显式指定输出的代码,
|
|||||||
import { stat, exists, readFile } from 'fs';
|
import { stat, exists, readFile } from 'fs';
|
||||||
```
|
```
|
||||||
|
|
||||||
上面代码的实质是从`fs`模块加载3个方法,其他方法不加载。这种加载称为“编译时加载”,即ES6可以在编译时就完成模块编译,效率要比CommonJS模块的加载方式高。当然,这也导致了没法引用ES6模块本身,因为它不是对象。
|
上面代码的实质是从`fs`模块加载3个方法,其他方法不加载。这种加载称为“编译时加载”,即ES6可以在编译时就完成模块加载,效率要比CommonJS模块的加载方式高。当然,这也导致了没法引用ES6模块本身,因为它不是对象。
|
||||||
|
|
||||||
由于ES6模块是编译时加载,使得静态分析成为可能。有了它,就能进一步拓宽JavaScript的语法,比如引入宏(macro)和类型检验(type system)这些只能靠静态分析实现的功能。
|
由于ES6模块是编译时加载,使得静态分析成为可能。有了它,就能进一步拓宽JavaScript的语法,比如引入宏(macro)和类型检验(type system)这些只能靠静态分析实现的功能。
|
||||||
|
|
||||||
@ -394,7 +394,9 @@ function incCounter() {
|
|||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
module.exports = {
|
module.exports = {
|
||||||
counter: counter,
|
get counter() {
|
||||||
|
return counter;
|
||||||
|
},
|
||||||
incCounter: incCounter,
|
incCounter: incCounter,
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user