The New ECMAScript5 Array Methods - NOW

I am more or less a convert from Prototype.js to jQuery. But the thing I found missing the most in jQuery is the functional style Array methods that are provided in Prototype.js. The methods that I normally use are simple, and I have been just recreating them myself in my projects: like collect, select, each, etc. But it's getting a bit tedious to do this for every new project and so I want a very lightweight library that just has these array methods. However, now that ECMAScript 5 is coming close to fruition, it makes a lot sense to use their method names and semantics. I have found that Safari, Firefox, and Flex all provide these methods already, so why not just jump on the bandwagon?

So, I have implemented these methods for environments that do not have them, as best I can to the spec. The methods are forEach, reduce, reduceRight, map, filter, every, someindexOf, and lastIndexOf.


The code and more info is at github and this project shall be named: ecma5array. Only less than 70 LOC.


blog comments powered by Disqus