Nodejs Study Notes -2.AMD specification

Source: Internet
Author: User

The Commonjs loading module is synchronous, and the AMD module is added to the non-synchronous, allowing for the designation of the callback function. Since Nodejs is mainly used for server programming, module files are generally present in the local, so load quickly, do not need to consider the non-synchronous loading, with COMMONJS can. But the browser is loaded from the server module, which requires the use of non-synchronous mode, GU Select AMD will be appropriate.

AMD uses the Define method to define modules such as:

1 define (['./b '],function () {  2      var a=function() {3     }; 4     return {5       a:a6   }; 7 })

AMD is allowed to output modules compatible with COMMONJS, so the notation can be changed to:

1 define (Funciton (require,exports,module) {2       var a=require ('./b '); 3       Exports. c=function() {4     }5 })

Nodejs Study Notes -2.AMD specification

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.