Coding in CoffeeScript:
Code Compilation & Installation:
Objects and Arrays:
The Conditional Assignments & Loops
Here, the loops will be comprehensions over arrays, objects, and ranges. The comprehensions replace for loops, with optional guard clauses and the value of array index. The array comprehensions are expressions and can be returned and assigned.
Check existence of a variable
De-structure & Inheritance:
The CoffeeScript has destructuring assignment syntax, and you can assign an array or object literal to a value. It breaks up and matches both sides against each other, assigning the values on the right to the variables on the left.
/you can write the constructor methods by writing method name followed by a colon. You have to leave a white space after each method name and can use the function operator also. The Splat is an easy way to accept multiple values as arguments to methods.
The fat arrow (with equal to sign followed by a greater than sign) can be used to define a function as well as bind it to the current value it. This feature is useful while using the callback libraries. Functions created with the fat arrow can access properties of the function. The latest version is 1.12.4 and CoffeeScript 2 is coming with support to ES2015 classes.
- Easy function definitions
- Syntax is simple to understand
- The Class definitions are easy
- Included in Ruby on Rails
- Quick and easy to test
- Clear mapping with the Source code
- You can get rid of unnecessary elements
- Significant white space in the coding
- Retains the Object-Oriented Features