Module
The idea of the ES6 module is to be as static as possible, so that the dependencies of the modules can be determined at compile time, as well as the input and output variables.
- Strict mode ES6 module automatically adopts strict mode
- The Export command is used to specify the external interface of the module, a module is a separate file, all variables inside the file, external is not available, if you want to read a variable inside the module, you must use the Export keyword to output the variable.
- Import command; change name with AS
- The overall load of the module; Specify an object with *, all output values are loaded on this object
- Export the default command; Specify the defaults for the module The import command does not use braces; Essentially, export default is to output a variable or method called default, and then the system allows you to take any name for it.
- The inheritance of the module;
- The essence of ES6 module loading; the COMMONJS module outputs a copy of the value, and the ES6 module outputs a reference to the value. ES6 module encountered module load command Import Yes, will not execute module, but only generate a dynamic read-only reference
- Cyclic loading;
- Cross-module constants;
ES6 notes Two