Extended array methods

JavaScript 1.6 or higher supports additional methods that can be used. However, they might not be cross-browser. The methods are listed in the table below.

MethodDescription
filter()Returns a new array that contains elements from an array that returned true based on the function used to filter it.
forEach()Calls a specified function for each element in the array.
every()Returns true if all elements in the array return true for a specified function used to test them.
indexOf()Returns the lowest index number for an element that has a value equal to the specified value sent as parameter.
lastIndexOf()Returns the highest index number for an element that has a value equal to the specified value sent as parameter.
map()Returns a new array that results from calling a specified function on every element in the array.
reduce()Runs a function on two values in the array at a time, from left to right until just a single value is left.
reduceRight()Runs a function on two values in the array at a time, from right to left until just a single value is left.
some()Returns true if one or more elements return true for the specified function used to test them.

Leave a Reply