今天发现这个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有兴趣的读者可到上面的提到的网址看看。
本文介绍了一个名为Underscore.js的JavaScript实用工具库,它提供了许多类似于Ruby编程语言的函数,适合进行功能性的编程。通过几个简单的示例,展示了如何在Node.js环境中使用Underscore.js进行数据操作。
1359

被折叠的 条评论
为什么被折叠?



