In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you what JavaScript module specifications, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The module specifications of JavaScript are: 1, CommonJS specification; 2, AMD (asynchronous module definition) specification; 3, CMD (common module definition) specification; 4, UMD specification (the combination of AMD and CommonJS).
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
There are three common JavaScript modularization specifications, CommonJS, AMD (Asynchronous Module definition) and CMD (Common Module definition).
Server: NodeJS service: CommonJS specification, the new version of Node can also enable ES6 Module function
Browser side: it mainly uses AMD specification and CMD specification, which has been gradually replaced by ES6 Module.
Modular specification
1. CommonJS specification
(1) each file is a module, each module has an independent scope, the variables and functions in the file are private, and other files are not available (unless assigned to global) (2) inside each module, the module variable represents the current module (3) the external interface of each file is the module.exports attribute (4) require is used to reference other modules. What you actually get is the module.exports attribute of other modules.
2. AMD (Asynchromous Module Definition-Asynchronous Module definition)
AMD is the standardized output of module definition by RequireJS in the process of promotion.
Use
Define module define (id?, dependencies?, factory) load module require ([module], callback)
3. CMD (Common Module Definition-Common module definition)
CMD is the standardized output of module definition by SeaJS in the process of promotion.
Use
Define module define (factory) load module require (id)
4. UMD (the combination of AMD and CommonJS)
UMD first determines whether a Node.js-enabled module (exports) exists, and if it does, it uses the Node.js module mode.
In determining whether AMD is supported (whether define exists or not), AMD is used to load the module if it exists.
(function (window, factory) {if (typeof exports = 'object') {module.exports = factory ();} else if (typeof define =' function' & & define.amd) {define (factory);} else {window.eventUtil = factory ();}}) (this, function () {/ / module...}) The above is all the contents of the article "what are the module specifications of JavaScript". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.