loading...

Discussion on: Why I LOVE CoffeeScript!(and why you should use it)

Collapse
eruizdechavez profile image
Erick Ruiz de Chavez

Just so you know, that is very old (most likely automatically generated) JavaScript.

With new JavaScript some of those expressions can be way shorter and/or better to understand.

// Functions:
square = x => x * x;

// Objects:
math = {
  root: Math.sqrt,
  square, // Short hand object assignment
  cube: x => x * square(x), // Arrow functions
};

// Splats:
race = (winner, ...runners) => print(winner, runners);

// Array comprehensions:
cubes = list.map(item => math.cube(item))
Collapse
seanolad profile image
Sean Author

True, I use modern JS conventions and still CoffeeScript manages to be more concise. Simply because it borrows the simple syntax from ruby. But it's good that you pointed out that the example code I used was based off some pre ES6 principles.