简体   繁体   English

是否有一个JavaScript库,它将缺少的标准迭代方法(filter,map,reduce,some ...)添加到Array中?

[英]Is there a JavaScript library that adds missing standard iteration methods (filter, map, reduce, some…) to Array?

Is there a JavaScript library which just adds some methods of Array, Object and other standard objects which have been standardized, but that are not available in all browsers? 是否有一个JavaScript库,它只是添加了一些已经标准化的Array,Object和其他标准对象的方法,但并不是所有浏览器都可用? I am thinking of iteration methods in Array such as filter() , map() , reduce() , some() , or keys() in Object . 我想到的迭代方法Arrayfilter() map() reduce() some()keys()Object

Note that I don't want the library to introduce anything fancy; 请注意,我不希望图书馆引入任何奇特的东西; just "standard" methods if they are not yet implemented in the current browser. 只是“标准”方法,如果它们尚未在当前浏览器中实现。

I believe you're looking for Underscore.js . 我相信你正在寻找Underscore.js http://documentcloud.github.com/underscore/ http://documentcloud.github.com/underscore/

jQuery is popular and has some array methods. jQuery很受欢迎,并且有一些数组方法。 But if you are looking for an larger set of JavaScript extensions, specifically the ones you mentioned, Prototype has my vote. 但是如果你正在寻找更大的JavaScript扩展,特别是你提到的那些扩展, Prototype有我的投票。

不知道这个的成熟度,但http://github.com/osteele/collections-js就是这么做的。

Dojo base also provides analogues to a number of the JS 1.6 Array methods within the dojo namespace, including indexOf , lastIndexOf , filter , map , forEach , every , and some . Dojo base还提供了dojo命名空间中许多JS 1.6 Array方法的类似物,包括indexOflastIndexOffiltermapforEacheverysome It doesn't have reduce . 它没有reduce I don't think it has an analogue to Object.keys either, presumably because a manual implementation of this is trivial, and dojo base is generally kept pretty tight in terms of what's allowed in. 我不认为它与Object.keys类似,大概是因为手动实现这个是微不足道的,并且dojo base通常在允许的内容方面保持相当紧密。

You can use Javascript 1.6, see this page in MDC . 您可以使用Javascript 1.6, 在MDC中查看此页面 It seems that most modern browsers support javascript 1.7 似乎大多数现代浏览器都支持javascript 1.7

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM