Returns a new array comprised of this array joined with other array(s) and/or value(s). |
|
|
|
Returns a new array comprised of this array joined with other array(s) and/or value(s). |
|
|
|
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.
The callback function is invoked with three arguments: the element value, the element index, the array being traversed. |
|
|
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 items in the array while that function is returning true. It returns true if the function returns true for every item it could visit.
The callback function is invoked with three arguments: the element value, the element index, the array being traversed. |
|
|
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.
The callback function is invoked with three arguments: the element value, the element index, the array being traversed. |
|
|
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 and returns an array of all items for which the function returns true.
The callback function is invoked with three arguments: the element value, the element index, the array being traversed. |
|
|
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 (callback) on every item in the array. The callback function is invoked only for indexes of the array which have assigned values.
The callback function is invoked with three arguments: the element value, the element index, the array being traversed. |
|
|
Sample
function printThemOut(element, index, array) {
application.output("a[" + index + "] = " + element);
}
var a = ['a', 'b', 'c'];
a.forEach(printThemOut);
|
|
|
|
|
Runs a function (callback) on every item in the array. The callback function is invoked only for indexes of the array which have assigned values.
The callback function is invoked with three arguments: the element value, the element index, the array being traversed. |
|
|
Sample
function printThemOut(element, index, array) {
application.output("a[" + index + "] = " + element);
}
var a = ['a', 'b', 'c'];
a.forEach(printThemOut);
|
|
|
|
|
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'));
|
|
|
|
|
(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'));
|
|
|
|
|
Checks whether an object is an array or not. |
|
|
Sample
var a = [1, 2, 3];
application.output(Array.isArray(a)); //prints true
application.output(Array.isArray(23)); //prints false
|
|
|
|
|
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(";");
|
|
|
|
|
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'));
|
|
|
|
|
(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.
The callback function is invoked with three arguments: the element value, the element index, the array being traversed. |
|
|
Sample
var a = ['a', 'b', 'c'];
var a2 = a.map(function(item) { return item.toUpperCase(); });
application.output(a2);
|
|
|
|
|
Runs a function on every item in the array and returns the results in an array.
The callback function is invoked with three arguments: the element value, the element index, the array being traversed. |
|
|
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();
|
|
|
|
|
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");
|
|
|
|
|
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");
|
|
|
|
|
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);
|
|
|
|
|
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.
The callback function is invoked with three arguments: the element value, the element index, the array being traversed. |
|
|
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));
|
|
|
|
|
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.
The callback function is invoked with three arguments: the element value, the element index, the array being traversed. |
|
|
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();
|
|
|
|
|
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();
|
|
|
|
|
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");
|
|
|
|
|
(arrayIndex, length, value1) |
|
|
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");
|
|
|
|
|
(arrayIndex, length, value1, value2) |
|
|
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");
|
|
|
|
|
(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");
|
|
|
|
|
|