Implementation of Stacks and Queues in JavaScript