Commonjs compared to ES6, AMD, and cmd

Source: Internet
Author: User

JavaScript,JavaScript is a scripting language with its own syntax and semantics, without JavaScript, and no other concepts.

About ES6, which can be directly understood as the enhanced version of JavaScript (adding new specifications, features and functionality) or the latest version, although slightly different, but also can be ignored (do not care about these details, hehe), a bit similar to the JAVA8 and Java language relationship, Also since there are ES6, there are also es 5 and Es 3, both of which are published in the development process of JavaScript.

Commonjs, AMD, and once-very-hot cmd are just a way to solve the dependency and reference problems between JavaScript files, so they are only a JavaScript package management specification . When you organize your JS code, you can choose the appropriate package management specifications according to your preference, but be careful to choose only one as much as possible.

Before the advent of Nodejs, JavaScript was primarily applied to the browser side, so Nodejs also understood that Nodejs was an extension of the application of JavaScript out of the browser, which also provided a running engine and related APIs, so Nodejs is a development kit for JavaScript to develop native applications, server applications , and note that because Nodejs uses JavaScript syntax, NODEJS is not a development language.

http://blog.csdn.net/yiifaa/article/details/54376458

ES6 {

Export: ' Can output multiple, output mode is {} ',

Export default: ' Only one output can be output with export, but it is not recommended ',

The parsing phase determines the external output interface, and the parsing phase generates an interface,

The module is not an object, the object is not loaded,

One of the interfaces (methods) can be loaded separately,

Static analysis, dynamic referencing, the output is a reference to the value, the value changes, the reference also changes, that is, the value in the original module changes, the value of the load will also change,

This point undefined

}

CommonJS {

Module.exports = ...: ' Can only output one, and the back will cover the above ',

Exports. ...: ' Can output multiple ',

The runtime determines the interface and the runtime loads the module,

The module is an object, the object is loaded,

The entire module is loaded, all the interfaces are loaded in,

The output is a copy of the value, that is, the value change in the original module does not affect the value that has already been loaded.

This points to the current module

}

Commonjs compared to ES6, AMD, and cmd

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.