data structures - How do you implement a Stack and a Queue in JavaScript? -


What is the best way to implement a stack and queue in JavaScript?

I am looking for Shunting-Yard algorithm and I'm going to need these data structures.

  Var stack = []; Stack.push (2); // Stack is now [2] stack.push (5); // Stack is now [2, 5] var i = stack.pop (); // Stack is now [2] Alert (i); // display 5 var queue = []; Queue.push (2); // queue is now [2] q Push (5); // queue is now [2, 5] var i = queue.shift (); // queue is now [5] warning (i); // displayed from 2  

"

)

Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -