CoffeeScript is a JS language translation tool that can reduce boilerplate code, making the code more concise and more readable. The converted JS files can be run on WEB browsers and are very convenient to use.
Basic introduction
CoffeeScript is a software that can help you translate JavaScript on your computer. You can directly convert the edited JavaScript code into JS text, so that you can run JS on the browser, saving you the time of manually editing JS. The software can run in a variety of programming and web development software. You need to load the software into the corresponding software to use it. When you edit a JavaScript document, you can start the CoffeeScript (language translation assistant) and convert the code. Compiled into equivalent JS, the compiled output is highly readable, has good printing effect, and runs faster than equivalent handwritten JavaScript.
Software features
1. Provide a relatively simple syntax that reduces boilerplate code, such as brackets and commas;
2. Use spaces as a way to organize code blocks;
3. Provide a simple syntax for expressing functions;
4. Provide class-based inheritance (optional, but very useful when developing applications)
Function introduction
1.CoffeeScript provides simple code compilation function
2. Can help you provide translation solutions when processing web type codes
3. Support package.json, support tomorrow.css
4. Supports most modern JavaScript
5. Support object Splats, aka object rest/extension syntax.
6. Support modern features you use; or you compile your code
7. Command line version of coffee available as Node.js utility
8. The core compiler does not depend on Node
9. Can run in any JavaScript environment or browser
Software installation
The CoffeeScript compiler itself is written in CoffeeScript, using the Jison parser generator. The command line version of coffee is a practical Node.js tool. However, the compiler does not rely on Node, but can run in any JavaScript execution environment, such as in the browser (see "Try CoffeeScript" above).
Before installation, you need the latest stable version of Node.js, and npm (Node Package Manager). CoffeeScript can be installed with npm:
npm install -g coffee-script
(If you don’t want to install it globally, you can remove the -g option.)
If you want to install the latest CoffeeScript on the master branch, you can clone CoffeeScript from the source code repository, or download the source code directly. You can also install the latest CoffeeScript compiler on the master branch through npm:
Or if you want to install it to /usr/local without using npm to manage it, enter the coffee-script directory and execute:
sudo bin/cake install
How to use
c, --compile Compile .coffee into .js file
w,--watch monitors file changes and outputs monitoring results
o,--output [DIR] Output the compiled result file to the specified directory
p,--print will compile the result
l, --lint If jsl (javascript lint) is installed, use lint to check the code
s, --stdio uses the output of other programs as the standard input of coffee and obtains the standard output of JavaScript.
e,--eval command line form