zh-rocco / fe-notes

:memo: 前端笔记

Home Page:https://zh-rocco.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

【JS】模块化

zh-rocco opened this issue · comments

commented

CommonJS 和 ES6 Module 区别

  • CommonJS 导出的是变量的一份拷贝; ES6 Module 导出的是变量的绑定(引用)
  • CommonJS 是单个值导出; ES6 Module 可以导出多个
  • CommonJS 是动态语法可以写在判断里; ES6 Module 静态语法只能写在顶层
  • CommonJSthis 是当前模块; ES6 Modulethisundefined

参考