This article is mainly on the array stack method and the characteristics of the queue method is described in detail, the need for friends can come to the reference, I hope to help you.
Stack method: LIFO (last in first outside) queue method: FIFO (first-in-outside) specific applications are as follows: code is as follows: <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html xmlns=" http://www.w3.org/1999/xhtml "> <head> <title> Stack method </title> <script type= "Text/javascript" > //Stack is a LIFO (last in first outside) data knot Construction function Basicpushorpop () { var colors=["Red", "green", "blue "]; var count=colors.push ("Pink"); the//push () method can receive any number of parameters and add them one at the end of the data and return the length of the modified array alert (count); var Temp=colors.pop (); the//pop () method removes the last item from the end of the array, reduces the length of the array, and then returns the removed item alert (temp); &NBSP} //queue data structure access rule is FIFO (in FirsT outside) function Basicshift () { var colors=new Array (); &n Bsp var count=colors.push ("Red", "blue");/push two alert (count); var temp=colors.shift ()//data from the first item in the queue, and remove , Ale RT ("Now the array length is: +colors.length+"--The removed item is: "+temp);" var newcount=colors.unshift ("Green", "Black"); the//unshift method represents adding any value of any type to the front of the queue. and returns the new array length alert ("Now the array length is:" +newcount);//ie Unshift method always returns undefined &NBSP} </script> </head> <body> <input type= "button" value= "Stack Method" onclick= " Basicpushorpop (); "/> <input type=" button "value=" Queue method "onclick=" Basicshift (); "/> </body> </ Html>