contents   index   previous   next



Array reverse()

syntax:

array.reverse()

return:

object - a new array consisting of the elements in the current Array object in reverse order.

 

description:

If the length of the current Array object is 0, then the current Array object is simply returned. Otherwise, a new Array object is created, and the elements of the current Array object are put into this new array in reverse order, preserving any empty or undefined elements.

 

example:

var a = new Array(1,2,3);

var b = a.reverse();

 

// The following code:

var array = new Array;

array[0] = "ant";

array[1] = "bee";

array[2] = "wasp";

array.reverse();

 

//produces the following array:

 

array[0] == "wasp"

array[1] == "bee"

array[2] == "ant"

 


Array shift()