Skip to content

Commit

Permalink
fix the Typo error:CommonJS and ES6 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
何文林 authored and YuChengKai committed Aug 14, 2018
1 parent f11fecb commit 29dbd51
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion JS/JS-ch.md
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ var load = function (module) {
对于 `CommonJS` 和 ES6 中的模块化的两者区别是:

- 前者支持动态导入,也就是 `require(${path}/xx.js)`,后者目前不支持,但是已有提案
- 前者是同步导入,因为用于服务端,文件都在本地,同步导入即使卡住主线程影响也不大。而后者是异步导入,因为用于浏览器,需要下载文件,如果也采用导入会对渲染有很大影响
- 前者是同步导入,因为用于服务端,文件都在本地,同步导入即使卡住主线程影响也不大。而后者是异步导入,因为用于浏览器,需要下载文件,如果也采用同步导入会对渲染有很大影响

- 前者在导出时都是值拷贝,就算导出的值变了,导入的值也不会改变,所以如果想更新值,必须重新导入一次。但是后者采用实时绑定的方式,导入导出的值都指向同一个内存地址,所以导入值会跟随导出值变化
- 后者会编译成 `require/exports` 来执行的
Expand Down
2 changes: 1 addition & 1 deletion JS/JS-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ Let's then talk about `module.exports` and `exports`, which have similar usage,
The differences between the modularizations in `CommonJS` and in ES6 are:
- The former supports dynamic imports, which is `require(${path}/xx.js)`; the latter doesn't support it yet, but there have been proposals.
- The former uses synchronous imports. Since it is used on the server end and files are local, it doesn't matter much even if the synchronous imports block the main thread. The latter uses asynchronous imports, because it is used in browsers in which file downloads are needed. Rendering process would be affected much if asynchronous import was used.
- The former uses synchronous imports. Since it is used on the server end and files are local, it doesn't matter much even if the synchronous imports block the main thread. The latter uses asynchronous imports, because it is used in browsers in which file downloads are needed. Rendering process would be affected much if synchronous import was used.
- The former copies the values when exporting. Even if the values exported change, the values imported will not change. Therefore, if values shall be updated, another import needs to happen. However, the latter uses realtime bindings, the values imported and exported point to the same memory addresses, so the imported values change along with the exported ones.
- In execution the latter is compiled to `require/exports`.
Expand Down

0 comments on commit 29dbd51

Please sign in to comment.