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

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -