今天发现这个Underscore.js,文档说
[url]http://documentcloud.github.com/underscore/[/url]
[quote]Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby)。[/quote]
提供了许多类似ruby风格的函数,这是我所喜欢的。
看几个例子。
安装
[quote]npm install underscore [/quote]
在nodes.js中测试
有兴趣的读者可到上面的提到的网址看看。
[url]http://documentcloud.github.com/underscore/[/url]
[quote]Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby)。[/quote]
提供了许多类似ruby风格的函数,这是我所喜欢的。
看几个例子。
安装
[quote]npm install underscore [/quote]
在nodes.js中测试
_ = require 'underscore'
_.each [1, 2, 3], (num) -> console.log(num)#=>1 2 3
_.each
one : 1
tow:2
three:3
(num,key) ->
console.log "#{key}:#{num}"
a1 = _.map [1,2,3,4], (num)-> num * 3
_.each a1, (num) -> console.log(num)#=>3 6 9 12
有兴趣的读者可到上面的提到的网址看看。