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.
Written by Esteban
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#