public interface JS5ArrayFunctions extends JS5ObjectFunctions, JSArrayFunctions
hasOwnProperty| Modifier and Type | Method and Description |
|---|---|
JSBoolean |
every(JS5Function predicate,
JS5Object o)
function every(predicate, o) test whether predicate is true for every element.
|
JS5Array |
filter(JS5Function predicate,
JS5Object o)
function filter(predicate, o) return array elements that pass a predicate.
|
void |
forEach(JS5Function f,
JS5Object o)
function forEach(f, o) invoke a function for each array element.
|
JSNumber |
indexOf(JS5Object value,
JSNumber start)
function indexOf(value, start) search an array.
|
JSNumber |
lastIndexOf(JS5Object value,
JSNumber start)
function lastIndexOf(value, start) search backwards through an array.
|
JS5Array |
map(JS5Function f,
JS5Object o)
function map(f, o) compute new array elements from old.
|
JS5Object |
reduce(JS5Function f,
JS5Object initial)
function reduce(f, initial) compute a value from the elements of an array.
|
JS5Object |
reduceRight(JS5Function f,
JS5Object initial)
function reduceRight(f, initial) reduce an array from right-to-left.
|
JSBoolean |
some(JS5Function predicate,
JS5Object o)
function some(predicate, o) test whether a predicate is true for any element.
|
concat, join, pop, push, reverse, shift, slice, sort, splice, unshifthasOwnProperty, isPrototypeOf, propertyIsEnumerable, toLocaleString, toString, valueOfJSBoolean every(JS5Function predicate, JS5Object o)
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 []
JS5Array filter(JS5Function predicate, JS5Object o)
Example
[1,2,3].filter(function(x){return x > 1}); // returns [2,3]
void forEach(JS5Function f, JS5Object o)
Example
var a = [1,2,3];
a.forEach(function(x,i,a){a[i]++;}); //a is now [2,3,4]
f - The function to invoke for each element of arrayo - An optional value on which f is invokedArrayJSNumber indexOf(JS5Object value, JSNumber start)
Example
['a','b','c'].indexOf('b'); //returns 1
['a','b','c'].indexOf('d'); //returns -1
['a','b','c'].indexOf('a',1); //returns -1
value - The value to search array for.start - An optional array index at which to begin the search. If omitted, 0 is used.Array,
lastIndexOf()JSNumber lastIndexOf(JS5Object value, JSNumber start)
JS5Array map(JS5Function f, JS5Object o)
Example
[1,2,3].map(function(x){return x*x;}); //returns [1,4,9]
JS5Object reduce(JS5Function f, JS5Object initial)
Example
[1,2,3].reduce(function(x,y){return x*y;}); //returns 6 ((1*2(*3))
f - A function that combines two values and returns a "reduced" valueinitial - An optional initial value to see the array reduction with.Array,
forEach(),
map(),
reduceRight()JS5Object reduceRight(JS5Function f, JS5Object initial)
Example
[2,10,60].reduceRight(function(x,y){return x/y;}); //returns 3 (60/10)/2
JSBoolean some(JS5Function predicate, JS5Object o)
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 []
predicate - A predicate function to test array elements.o - The optional this value for the invocations of predicate.Array