How to make a array as a stack using JavaScript?
Submitted by: AdministratorThe 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
<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
Top JavaScript Questions
☺ | Are Java and JavaScript the Same? |
☺ | How to convert numbers to strings using JavaScript? |
☺ | What does isNaN function do? |
☺ | How to read and write a file using JavaScript? |
☺ | What looping structures are there in JavaScript? |
Top Top World Wide Web Categories
☺ | Cascading Style Sheet CSS Interview Questions. |
☺ | HTML5 Interview Questions. |
☺ | Basic Internet Interview Questions. |
☺ | Domain Name System (DNS) Interview Questions. |
☺ | JavaScript Interview Questions. |