From http://stackoverflow.com/questions/1590247/how-do-you-implement-a-stack-and-a-queue-in-javascript