Specifications
Reverses the items in the array.
var x = new Array( "a", "b", "c", "d" );
x.reverse(); // x == [ "d", "c", "b", "a" ]
reverse( )
Shifts (that is, removes) the bottom-most (left-most) item off the
array and returns it.
var x = new Array( "a", "b", "c" );
var y = x.shift(); // y == "a" x == [ "b", "c" ]
shift( ) : Object
Copies a slice of the array from the item with the given starting
index, startIndex, to the item before the item with the given
slice( startIndex : Number,
optEndIndex : Number ) :
Array
ending index, optEndIndex. If no ending index is given, all items
from the starting index onward are sliced.
var x = new Array( "a", "b", "c", "d" );
var y = x.slice( 1, 3 ); // y == [ "b", "c" ]
var z = x.slice( 2 ); // z == [ "c", "d" ]
Sorts the items in the array using string comparison. For
customized sorting, pass the sort() function a comparison function,
sort(
optComparisonFunction :
function or Function )
optComparisonFunction, that has the following signature and
behavior:
function comparisonFunction( a, b ) // signature
The function must return an integer as follows:
• -1 if a < b
• 0 if a == b
• 1 if a > b
Example 1:
var x = new Array( "d", "x", "a", "c" );
x.sort(); // x == [ "a", "c", "d", "x" ]
Example 2:
function numerically( a, b ) { return a < b ? -1 : a > b
? 1 : 0; }
var x = new Array( 8, 90, 1, 4, 843, 221 );
x.sort( numerically ); // x == [ 1, 4, 8, 90, 221, 843 ]
Splices items into the array and out of the array. The first
argument, startIndex, is the start index. The second argument,
splice( startIndex : Number,
replacementCount :
Number, optItem1 : Object,
... optItemN : Object )
replacementCount, is the number of items that are to be replaced.
Make the second argument 0 if you are simply inserting items.
The remaining arguments are the items to be inserted. If you are
simply deleting items, the second argument must be > 0 (that is,
373
Enfocus Switch 10