How to make a array as a stack using JavaScript?

Submitted by: Administrator
The pop() and push() functions turn a harmless array into a stack in JavaScript...

<script type="text/javascript">
var numbers = ["one", "two", "three", "four"];
numbers.push("five");
numbers.push("six");
document.write(numbers.pop());
document.write(numbers.pop());
document.write(numbers.pop());
</script>

This produces
sixfivefour
Submitted by: Administrator

Read Online JavaScript Job Interview Questions And Answers