Home > DeveloperSection > Interviews > How to shift and unshift using JavaScript?

Posted on    October-17-2011 12:12 AM

 JavaScript JavaScript 
 1 Answer(s)
  2187  View(s)
Rate this:

Chris Anderson
Chris Anderson

Total Post:197

Posted on    October-17-2011 12:00 AM

<script type="text/javascript">
var numbers = ["one", "two", "three", "four"];
document.write(" "+numbers.shift());
document.write(" "+numbers.shift());
document.write(" "+numbers.shift());
This produces
zero one two
shift, unshift, push, and pop may be used on the same array. Queues are easily implemented using combinations.

Don't want to miss updates? Please click the below button!

Follow MindStick