1var stack = [];
2stack.push(2); // stack is now [2]
3stack.push(5); // stack is now [2, 5]
4var i = stack.pop(); // stack is now [2]
5alert(i); // displays 5
6
7var queue = [];
8queue.push(2); // queue is now [2]
9queue.push(5); // queue is now [2, 5]
10var i = queue.shift(); // queue is now [5]
11alert(i); // displays 2
12taken from "9 javascript tips you may not know"
1var stack = [];
2stack.push(2); // stack is now [2]
3stack.push(5); // stack is now [2, 5]
4var i = stack.pop(); // stack is now [2]
5alert(i); // displays 5
6
7var queue = [];
8queue.push(2); // queue is now [2]
9queue.push(5); // queue is now [2, 5]
10var i = queue.shift(); // queue is now [5]
11alert(i); // displays 2
12