Shenma is a simple cmd mode of code. That's it!

Source: Internet
Author: User

The wolf is studying "how to find the same color blocks that are connected together ?" Algorithm problems suddenly feel like I need a development mode, or else I feel like my code is messy.

It may be because of studying algorithms, which makes the idea of Wolf very clear. In addition, nodejs and seajs, which have been used for almost a year, are very clear about the cmd api. I will not talk much about it, but look at the code.

Similar to seajs, it conforms to the CMD mode,

VaR require, define; (function () {var module = {} require = function (name) {return module [name]} define = function (name, func) {var exports = module [name] = {} module. exports = exports func (require, exports, module) return exports }})()

Then test

Define ("solve", function (require, exports, module ){

Module. Exports. Name = 21
Module. Exports. Solve = function (){
Console. Log (this. Name)
}
})
Define ("test", function (require, exports, module ){
Require ("solve"). Solve ()

})
Require ("test ")

Finally, the result is successfully output, indicating that the CMD mode can be implemented,

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.