Interface JS5ArrayFunctions
-
- All Superinterfaces:
JS5ObjectFunctions,JSArrayFunctions,JSObjectFunctions
public interface JS5ArrayFunctions extends JS5ObjectFunctions, JSArrayFunctions
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description JSBooleanevery(JS5Function predicate, JS5Object o)function every(predicate, o) test whether predicate is true for every element.JS5Arrayfilter(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.JSNumberindexOf(JS5Object value, JSNumber start)function indexOf(value, start) search an array.JSNumberlastIndexOf(JS5Object value, JSNumber start)function lastIndexOf(value, start) search backwards through an array.JS5Arraymap(JS5Function f, JS5Object o)function map(f, o) compute new array elements from old.JS5Objectreduce(JS5Function f, JS5Object initial)function reduce(f, initial) compute a value from the elements of an array.JS5ObjectreduceRight(JS5Function f, JS5Object initial)function reduceRight(f, initial) reduce an array from right-to-left.JSBooleansome(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, unshift
-
Methods inherited from interface org.fife.rsta.ac.js.ecma.api.ecma3.functions.JSObjectFunctions
hasOwnProperty, isPrototypeOf, propertyIsEnumerable, toLocaleString, toString, valueOf
-
-
-
-
Method Detail
-
every
JSBoolean every(JS5Function predicate, JS5Object o)
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 []
-
filter
JS5Array filter(JS5Function predicate, JS5Object o)
function filter(predicate, o) return array elements that pass a predicate.Example
[1,2,3].filter(function(x){return x > 1}); // returns [2,3]
-
forEach
void forEach(JS5Function f, JS5Object o)
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:
Array
-
indexOf
JSNumber indexOf(JS5Object value, JSNumber start)
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:
Array,lastIndexOf()
-
lastIndexOf
JSNumber lastIndexOf(JS5Object value, JSNumber start)
function lastIndexOf(value, start) search backwards through an array.
-
map
JS5Array map(JS5Function f, JS5Object o)
function map(f, o) compute new array elements from old.Example
[1,2,3].map(function(x){return x*x;}); //returns [1,4,9]
-
reduce
JS5Object reduce(JS5Function f, JS5Object initial)
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:
Array,forEach(),map(),reduceRight()
-
reduceRight
JS5Object reduceRight(JS5Function f, JS5Object initial)
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
-
some
JSBoolean some(JS5Function predicate, JS5Object o)
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:
Array
-
-