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.