(value1, [value2], [valueN]) |
|
|
Returns a new array comprised of this array joined with other array(s) and/or value(s). |
|
|
Runs a function on items in the array while that function is returning true. It returns true if the function returns true for every item it could visit. |
|
Sample
function isNumber(value) { return typeof value == 'number'; }
var a1 = [1, 2, 3];
application.output(a1.every(isNumber));
var a2 = [1, '2', 3];
application.output(a2.every(isNumber));
|
|
|
|
|
Runs a function on every item in the array and returns an array of all items for which the function returns true. |
|
Sample
var a1 = ['a', 10, 'b', 20, 'c', 30];
var a2 = a1.filter(function(item) { return typeof item == 'number'; });
application.output(a2);
|
|
|
|
|
Runs a function on every item in the array. |
|
Sample
function printThemOut(params) { application.output(params);}
var a = ['a', 'b', 'c'];
a.forEach(printThemOut);
|
|
|
|
|
(searchElement, [fromIndex]) |
|
|
Returns the first index at which a given element can be found in the array, or -1 if it is not present. |
|
Sample
var a = ['a', 'b', 'a', 'b', 'a'];
application.output(a.indexOf('b'));
application.output(a.indexOf('b', 2));
application.output(a.indexOf('z'));
|
|
|
|
|
Puts all elements in the array into a string, separating each element with the specified delimiter |
|
Sample
var words = new Array("limit","lines","finish","complete","In","Out");
var jwords = words.join(";");
|
|
|
|
|
(searchElement, [fromIndex]) |
|
|
Returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, starting at fromIndex. |
|
Sample
var a = ['a', 'b', 'c', 'd', 'a', 'b'];
application.output(a.lastIndexOf('b'));
application.output(a.lastIndexOf('b', 4));
application.output(a.lastIndexOf('z'));
|
|
|
|
|
Runs a function on every item in the array and returns the results in an array. |
|
Sample
var a = ['a', 'b', 'c'];
var a2 = a.map(function(item) { return item.toUpperCase(); });
application.output(a2);
|
|
|
|
|
Pops the last string off the array and returns it. |
|
Sample
var words = new Array("limit","lines","finish","complete","In","Out");
var lastword = words.pop();
|
|
|
|
|
(value1, [value2], [valueN]) |
|
|
Mutates an array by appending the given elements and returning the new length of the array. |
|
Sample
var words = new Array("limit","lines","finish","complete");
words.push("In","Out");
|
|
|
|
|
Puts array elements in reverse order. |
|
Sample
var words = new Array("limit","lines","finish","complete","In","Out");
words.reverse();
|
|
|
|
|
Decreases array element size by one by shifting the first element off the array and returning it. |
|
Sample
var words = new Array("limit","lines","finish","complete","In","Out");
words.shift();
|
|
|
|
|
The slice method creates a new array from a selected section of an array. |
|
Sample
var words = new Array("limit","lines","finish","complete","In","Out");
var nwords1 = words.slice(3, 5);
|
|
|
|
|
Runs a function on items in the array while that function returns false. It returns true if the function returns true for any item it could visit. |
|
Sample
function isNumber(value) { return typeof value == 'number'; }
var a1 = [1, 2, 3];
application.output(a1.some(isNumber));
var a2 = [1, '2', 3];
application.output(a2.some(isNumber));
|
|
|
|
|
Sorts the array elements in dictionary order or using a compare function passed to the method. |
|
Sample
var words = new Array("limit","lines","finish","complete","In","Out");
words.sort();
|
|
|
|
|
(arrayIndex, length, [value1], [value2], [valueN]) |
|
|
It is used to take elements out of an array and replace them with those specified. |
|
Sample
var words = new Array("limit","lines","finish","complete","In","Out");
var nwords1 = words.splice(3, 2, "done", "On");
|
|
|
|
|
Places element data at the start of an array. |
|
Sample
var words = new Array("finish","complete","In","Out");
words.unshift("limit","lines");
|
|
|
|
|
|