Last Updated: February 25, 2016
·
345
· fr0gs

Syntax for arrays in Coffeescript

Imagine you have an array such as:

l = [1, 2, 3, 4]

This line:

k = x*2 for x in l

Will return : 12, and this line:

k = (x*2 for x in l)

will return [2, 4, 6, 8]

Without parenthesis in CoffeeScript it is equivalent to a forEach() in javascript.