Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JavaScriptQuestions How to shift and unshift using JavaScript?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


samar
How to shift and unshift using JavaScript?
1 Answer(s)      4 years and 2 months ago
Posted in : JavaScript Questions


How to shift and unshift using JavaScript?


Advertisement
View Answers

November 10, 2010 at 5:48 PM


As the pop() method removes and returns the last element, the shift() method removes and returns the first element of an array object. Since the first element is removed and returned this also affects the length of the array.

<script type="text/javascript">
         var rose =["Welcome","to","roseindia","Technologies"];
         document.write(rose.shift() + "<br />");
         document.write(rose.shift() + "<br />");
         document.write(rose);
      </script>


Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com