1.

How To Make A Array As A Stack Using Javascript?

Answer»

The POP() and push() functions turn a harmless array into a stack
<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

The pop() and push() functions turn a harmless array into a stack
<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



Discussion

No Comment Found