Coffeescript First Experience

Source: Internet
Author: User

The first time was attracted, personally feel worth a use, concise, practical, skilled words to write the code itself has become beautiful, and looks very tall on the wood has

Installation

NPM Install Coffee-script-g

NPM is a package management tool for Nodejs, and it can be used with NPM if you download and install Nodejs. - g refers to installing the package into a global path so that you can use it wherever the current path is

Incidentally, how to change the global path

NPM root-g  // View global path npm config set prefix path/to/global_modules  // set path prefix, NPM will automatically create the Node_modules directory under this directory to store various packages NPM config set cache Path/to/global_cache

Finally, add your Path/to/global_modules path to the system's environment variable and you 're done.

Use

Now you can use the Coffee command in any location.

The most common is to compile the. coffee file into a. js file.

Coffee-o path/to/js/-C path/to/coffee/  // compiles all. coffee files under coffee/to the same name. js file under js/

There are other very useful commands such as listening, etc., see the official website tutorial

Better Coffeescript plugin recommended for players using sublime

Use coffee to write the previous code

Set = (name, value, options = {})ifValue isNULLOptions.maxage= 0Options.expires=-1ifValue andtypeofValue is ' object 'value=json.stringify (value) str= encodeURIComponent (name) + ' = ' +encodeURIComponent (value)ifOptions.expires?D=NewDate () d.settime (D.gettime ()+ options.expires * 1000) Str+ = '; Expires= ' +d.toutcstring ()ifOptions.maxage? Then str + = '; Max-age= ' +Options.maxageifOptions.path? Then str + = '; Path= ' +Options.pathifOptions.domain? Then str + = '; Domain= ' +Options.domainifOptions.secure? Then str + = '; SecureDocument.cookie= str

For Coffeescript I personally feel that the need to spit groove is the official code in the call function when the parameters () are omitted, so that the readability is significantly worse, when writing is still more comfortable with parentheses

Coffeescript First Experience

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.