Interviewer And Interviewee Guide

JavaScript Interview Question:

How to shift and unshift using JavaScript?

Submitted by: Administrator
<script type="text/javascript">
var numbers = ["one", "two", "three", "four"];
numbers.unshift("zero");
document.write(" "+numbers.shift());
document.write(" "+numbers.shift());
document.write(" "+numbers.shift());
</script>

This produces
zero one two
shift, unshift, push, and pop may be used on the same array in JavaScript. Queues are easily implemented using combinations.
Submitted by: Administrator

Read Online JavaScript Job Interview Questions And Answers
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.