Stack data structure JavaScript

by Mohan 2012-09-20 23:18:45



Stack data structure
JavaScript 1.5 Array object has all needed methods to be used as a stack.
var stack = [];
stack.push( 111 );
stack.push( 2.22 );
stack.push( 'ccc' );

Print( stack ); // prints: 111,2.22,ccc

Print( stack.pop() ); // prints: ccc
Print( stack.pop() ); // prints: 2.22

915
like
0
dislike
0
mail
flag

You must LOGIN to add comments