Warping it up!

Fini Alring’s Glossy Tech Zine

Mozilla: New JS Array Methods

As an “old-schoolJavaScript hacker, I dreadfully remember the days before the Array() object. Not that we didn’t survive without it, but it’s good to have this sort of stuff properly implemented in a language..

After a whole lot of silence (not forgetting the yet to be publicized E4X) in the land of JavaScript / ECMAScript finally something is happening to the Array spec, Mozilla has added new methods which will be publicly available in Firefox 1.5. However I have not been able to locate the draft specification of EMCA-262 and thus I can not confirm if these methods are actually in the coming ECMA-262 Edition 4.

These are the new Array methods:

Item location methods:
indexOf( )
Returns the index of the given item’s first occurrence.
lastIndexOf( )
Returns the index of the given item’s last occurrence.
Iterative methods are:
every( )
Runs a function on every item in the array and returns true if the function returns true for every item.
filter( )
Runs a function on every item in the array and returns an array of all items for which the function returns true.
forEach( )
Runs a function on every item in the array.
map( )
Runs a function on every item in the array and returns the results in an array.
some( )
Runs a function on every item in the array and returns true if the function returns true for any one item.

Visit webreference.com for examples on how to use these methods.

Mozilla’s New Array Methods – WebReference.com

Related Posts:

  • No Related Posts

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

One Response to “Mozilla: New JS Array Methods”

  1. Alex Says:

    Thank You

Leave a Reply