Simple Stack Example : Stack « Language Basics « JavaScript DHTML






Simple Stack Example

<HTML>
<HEAD>
<TITLE> 
Simple Stack Example 
</TITLE>
</HEAD>
<BODY>
<H1>
<SCRIPT> 
var stack = new Array(); 
stack.push("Me", "Two"); 

for (var i = 0; i < stack.length; i++){ 
   document.write(stack[i] + "<br>"); 
} 

document.write (stack.pop() + "<br>"); 

for (var i = 0; i < stack.length; i++){ 
   document.write(stack[i] + "<br>"); 
} 
</SCRIPT>
</H1>
</BODY>
</HTML>
           
       








Related examples in the same category

1. Pushing, Popping, and Displaying the Contents of a Stack