views:

88

answers:

5

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? I am thinking of iteration methods in Array such as filter(), map(), reduce(), some(), or keys() in 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.

+8  A: 

I believe you're looking for Underscore.js. http://documentcloud.github.com/underscore/

racetrack
+1 Stricter application and much lighter than my suggestions.
Jason McCreary
+1 Underscore is the best javascript normalization library out there that I'm aware of ... and it's certainly the lightest.
Sean Vieira
Recently, I ran across Underscore, but didn't pay enough attention to it. Now, I am going again though their documentation more carefully, and man is it good! It is just a pleasure to read their source code. Thank you for this recommendation.
Alessandro Vernet
+1  A: 

jQuery is popular and has some array methods. But if you are looking for an larger set of JavaScript extensions, specifically the ones you mentioned, Prototype has my vote.

Jason McCreary
A: 

You can use Javascript 1.6, see this page in MDC. It seems that most modern browsers support javascript 1.7

Xenofex
+1  A: 

Dont know the maturity of this, but http://github.com/osteele/collections-js does exactly that.

Quickredfox
+1  A: 

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. It doesn't have 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.

Ken