【发布时间】:2012-03-26 08:13:13
【问题描述】:
CoffeeScript 带有一些 helper functions。如何使用它们?以flatten(Array) 为例。
【问题讨论】:
标签: coffeescript
CoffeeScript 带有一些 helper functions。如何使用它们?以flatten(Array) 为例。
【问题讨论】:
标签: coffeescript
这些函数似乎是供 CoffeeScript 编译器私人使用的。如果您想要这些功能,最好使用像 Underscore.js 这样的通用库。
coffee> _ = require('underscore')
coffee> _.flatten [1, 2, 3, [4, 5]]
[ 1, 2, 3, 4, 5 ]
【讨论】:
helpers.coffee 的存在只是为了让 CoffeeScript 编译器不需要像 Underscore 这样的外部依赖。
u = require('underscore')u.flatten [1,2,3,[4,5]]