CommonJS, CMD, AMD, and NodeJS create the future of JavaScript. commonjsnodejs

Source: Internet
Author: User

CommonJS, CMD, AMD, and NodeJS create the future of JavaScript. commonjsnodejs

CMDIt is developed by Yubo Dashen in China.SeaJSWhich belongsCommonJSIn additionAMDThe framework isRequireJS

1. Both are an implementation of Asynchronuous Module Definition;

2,CMDAndAMDAllCommonJSIs a standard implementation Definition,RequireJSAndSeaJSIs the corresponding practice;

3,CMDAndAMDDifferences:CMDIt is equivalent to loading on demand. when defining a module, you do not need to create a dependency module immediately. You can use require as needed, which is more convenient.AMDOn the contrary, when defining a module, You need to define the dependency module and introduce it into the factory as a form parameter.
See the following example for differences:

// Define the module define (['dep1', 'dep2'], function (dep1, dep2) in AMD mode {// only the specified module return function () can be used internally () {};}); // define (function (require, exports, module) {// if you need a XX module, you can introduce var xx = require ('xx ');});

4. The JavaScript language is weakly structured.CommonJSDefine some specifications,CMDAndAMDYou need to define the module to manage the Code to make it easier to maintain. In addition,NodeJSThe birth of the module, the standard definition of the module, and the introduction of the package (NPM) concept make JS management no longer difficult!

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.