Queue method
A LIFO "LIFO " access rule relative to the stack data structure, and the access rules for the queue data structure are FIFO
Here refers to a method shift (); It is able to move the first item in the array and return the item, while reducing the length of the 1;//by a bit like pop ()
Instance:
var colors = [' red ', ' green '];
var item = Colors.shift ();
alert (colors); Green
alert (item); Red
Alert (colors.length)//1;
A Unshift () method is also provided.
Usage and shift () opposite;
The shift () and unshift () operations are all the first items of the array;// push () and pop () are all for the tail of the array;
Unshift the length of the returned array;
Reorder Methods
The reverse () method is to reverse the original order of the array;
The sort () method is to arrange the array items in ascending order, which is the ToString () method that invokes the array, and then compares the resulting string to determine how to sort, note that even if each item value in the array is a number, the sort () method compares the string;
The sort () method can receive a comparison function as a parameter to specify which value is in front of which value;
Queue Method & Reorder method for array--js study note 2015-6-27 (68th Day)