CommonJS, CMD, AMD, and NodeJS create the future of JavaScript. commonjsnodejs
CMD
It is developed by Yubo Dashen in China.SeaJS
Which belongsCommonJS
In additionAMD
The framework isRequireJS
1. Both are an implementation of Asynchronuous Module Definition;
2,CMD
AndAMD
AllCommonJS
Is a standard implementation Definition,RequireJS
AndSeaJS
Is the corresponding practice;
3,CMD
AndAMD
Differences:CMD
It 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.AMD
On 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.CommonJS
Define some specifications,CMD
AndAMD
You need to define the module to manage the Code to make it easier to maintain. In addition,NodeJS
The 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.