Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use CoffeeScript's built-in helper functions?

Tags:

coffeescript

CoffeeScript comes with a few helper functions. How to use them? flatten(Array) for example.

like image 748
powerboy Avatar asked Mar 26 '12 00:03

powerboy


1 Answers

These functions seem to be intended for private use by the CoffeeScript compiler. It might be better to use a general-purpose library like Underscore.js if you want these sort of features.

coffee> _ = require('underscore')
coffee> _.flatten [1, 2, 3, [4, 5]]
[ 1, 2, 3, 4, 5 ]
like image 199
Jon Gauthier Avatar answered Oct 18 '22 07:10

Jon Gauthier