<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<title>Stack Method</title>
<script type="text/javascript">
//Stack is a data structure that comes in and out after LIFO (last in first outside)
function basicPushOrPop(){
var colors=["red","green","blue"];
var count=("pink");//push() method can receive any number of parameters, add them one by one to the end of the data, and return the length of the modified array
alert(count);
var temp=();//pop() method removes the last item from the end of the array, reduces the length value of the array, and then returns the removed item
alert(temp);
}
//The access rule of the queue data structure is FIFO(first in first outside)
function basicShift(){
var colors=new Array();
var count=("red","blue");//Push two items
alert(count);
var temp=();//Fetch the data of the first item in the queue and remove it
alert("Now the array length is: "++"--the removed item is: "+temp);
var newcount=("green","black");//unshift method means adding any arbitrary type of values to the front end of the queue and returning the new array length
alert("Now the array length is: "+newcount);//ie unshift method always returns undefined
}
</script>
</head>
<body>
<input type="button" value="stack method" onclick="basicPushOrPop();" />
<input type="button" value="queuing method" onclick="basicShift();" />
</body>
</html>