What is the difference between es6 and node

WBOY
Release: 2022-08-18 17:09:42
Original
1738 people have browsed it

The difference between es6 and node: 1. es6 supports static compilation, while node adopts the "common.js" specification and does not support static compilation; 2. es6 does not support synchronous loading for the import() function, while node supports synchronous loading. Loading; 3. The es6 export value and the import value both point to the same memory and are dynamically updated, but node does not exist.

What is the difference between es6 and node

The operating environment of this tutorial: Windows 10 system, ECMAScript version 6.0, Dell G3 computer.

What is the difference between es6 and node

Node module

Node uses the CommonJS specification, and the loading method is synchronous loading; it has four important Environment variables: module, exports, require, global. In actual use, the module variable represents the current module, and exports is an attribute of the module, indicating the external output interface. Loading a module actually loads the module.exports attribute of the module. Use require to load modules (synchronously).

Node provides an exports variable for every module, pointing to module.exports, which is equivalent to a line of code in the header of each module:

var exports = module.exports
Copy after login

exports is just one of module.exports Reference, pointing to the address where the module.exports object is located

ES6 module

In ES6 modularization, use import to introduce modules and export to export modules, but babel compilation is required A code that the browser can recognize.

Both export and export default can be used to export constants, functions, files, modules, etc.;

In a file or module, there can be multiple exports and imports, but there is only one export default;

Export through export, you need to add {} when importing, export default does not need to;

import { Input } from 'element-ui'   //export
import Vue from 'vue'//export default
Copy after login

export can export variable expressions, export default cannot.

Difference

What is the difference between es6 and node

[Related recommendations: javascript video tutorial, webfrontend

The above is the detailed content of What is the difference between es6 and node. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
es6
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template