[英]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
. 我想到的迭代方法在
Array
如filter()
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/
不知道这个的成熟度,但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方法的类似物,包括indexOf
, lastIndexOf
, filter
, map
, forEach
, every
和some
。 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.