Interface JS5ArrayFunctions
- All Superinterfaces:
JS5ObjectFunctions,JSArrayFunctions,JSObjectFunctions
-
Method Summary
Modifier and TypeMethodDescriptionevery(JS5Function predicate, JS5Object o) function every(predicate, o) test whether predicate is true for every element.filter(JS5Function predicate, JS5Object o) function filter(predicate, o) return array elements that pass a predicate.voidforEach(JS5Function f, JS5Object o) function forEach(f, o) invoke a function for each array element.function indexOf(value, start) search an array.lastIndexOf(JS5Object value, JSNumber start) function lastIndexOf(value, start) search backwards through an array.map(JS5Function f, JS5Object o) function map(f, o) compute new array elements from old.reduce(JS5Function f, JS5Object initial) function reduce(f, initial) compute a value from the elements of an array.reduceRight(JS5Function f, JS5Object initial) function reduceRight(f, initial) reduce an array from right-to-left.some(JS5Function predicate, JS5Object o) function some(predicate, o) test whether a predicate is true for any element.Methods inherited from interface org.fife.rsta.ac.js.ecma.api.ecma3.functions.JSArrayFunctions
concat, join, pop, push, reverse, shift, slice, sort, splice, unshiftMethods inherited from interface org.fife.rsta.ac.js.ecma.api.ecma3.functions.JSObjectFunctions
hasOwnProperty, isPrototypeOf, propertyIsEnumerable, toLocaleString, toString, valueOf
-
Method Details
-
every
function every(predicate, o) test whether predicate is true for every element.Example
[1,2,3].every(function(x){return x < 5;} //=>true [1,2,3].every(function(x){return x < 2;} //=>false [].every(function(x){return false;} //=>true, always true for []- Parameters:
predicate- A predicate function to test array elementso- The optional this value for invocations of predicate.- Since:
- Standard ECMA-262 5th. Edition
- See Also:
-
filter
function filter(predicate, o) return array elements that pass a predicate.Example
[1,2,3].filter(function(x){return x > 1}); // returns [2,3]- Parameters:
predicate- The function to invoke to determine whether an element of array will be included in the returned array.o- An optional value on which predicate is invoked- Since:
- Standard ECMA-262 5th. Edition
- See Also:
-
forEach
function forEach(f, o) invoke a function for each array element.Example
var a = [1,2,3]; a.forEach(function(x,i,a){a[i]++;}); //a is now [2,3,4]- Parameters:
f- The function to invoke for each element of arrayo- An optional value on which f is invoked- Since:
- Standard ECMA-262 5th. Edition
- See Also:
-
indexOf
function indexOf(value, start) search an array.Example
['a','b','c'].indexOf('b'); //returns 1 ['a','b','c'].indexOf('d'); //returns -1 ['a','b','c'].indexOf('a',1); //returns -1- Parameters:
value- The value to search array for.start- An optional array index at which to begin the search. If omitted, 0 is used.- Since:
- Standard ECMA-262 5th. Edition
- See Also:
-
lastIndexOf
function lastIndexOf(value, start) search backwards through an array.- Parameters:
value- The value to search array for.start- An optional array index at which to begin the search. If omitted, the search begins at the last element- Since:
- Standard ECMA-262 5th. Edition
- See Also:
-
map
function map(f, o) compute new array elements from old.Example
[1,2,3].map(function(x){return x*x;}); //returns [1,4,9]- Parameters:
f- The function to invoke for each element of array. Its return becomes the elements of the returned arrayo- An optional value of which f is invoked- Since:
- Standard ECMA-262 5th. Edition
- See Also:
-
reduce
function reduce(f, initial) compute a value from the elements of an array.Example
[1,2,3].reduce(function(x,y){return x*y;}); //returns 6 ((1*2(*3))- Parameters:
f- A function that combines two values and returns a "reduced" valueinitial- An optional initial value to see the array reduction with.- Since:
- Standard ECMA-262 5th. Edition
- See Also:
-
reduceRight
function reduceRight(f, initial) reduce an array from right-to-left.Example
[2,10,60].reduceRight(function(x,y){return x/y;}); //returns 3 (60/10)/2- Parameters:
f- A function that combines two values and returns a "reduced" valueinitial- An optional initial value to see the array reduction with.- Since:
- Standard ECMA-262 5th. Edition
- See Also:
-
some
function some(predicate, o) test whether a predicate is true for any element.Example
[1,2,3].some(function(x){return x > 5;} //=>false [1,2,3].some(function(x){return x > 2;} //=>true [].some(function(x){return true;} //=>false, always false for []- Parameters:
predicate- A predicate function to test array elements.o- The optional this value for the invocations of predicate.- Since:
- Standard ECMA-262 5th. Edition
- See Also:
-