A stack works on the principle of Last In - First Out (LIFO) since (as you can imagine from our example) removing a plate other than the top one on the stack is not very easy without first removing those plates above it in the stack.
You might think that the easiest way of creating an equivalent construct is to create an Array and just keep track of how many entries that the array is supposed to contain. For example:
var stack = ;
var entry2 = stack.pop();
Using push() always adds a new entry onto the end of an array. Using pop() always retrieves the last entry from an array as well as removing that entry from the array. This removes the need for us to keep track separately of how many entries our array contains when we are using it like this.
This article written by Stephen Chapman, Felgall Pty Ltd.