How to shift and unshift using JavaScript?

Ads
 

How to shift and unshift using JavaScript?

How to shift and unshift using JavaScript?

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>

Ads









Related Tutorials/Questions & Answers:
How to shift and unshift using JavaScript?
How to write javascripts - JSP-Servlet
Advertisements
How to write javascripts - JSP-Servlet
Javascripts events
left shift and rigth shift operators
Unsigned right shift ">>>" Operator
Shift Array Elements in Java
JavaScript Array unshift
Java Left Shift "<<" Operator
about ALT ,CTRL and SHIFT
about ALT ,CTRL and SHIFT
Java Right Shift ">>" Operator
Version of com.shapesecurity>shift dependency
right and left shift operators
Shifting Row Using JSP
How are joins handled using Hinernate?
How to configure Spring using Annotation
How to zip a file using javascrip?
How to design a form using java?
how to create using jsp
Version of com.shapesecurity>shift-semantics dependency
How to Create Instance using PHP
how to host a website using asp.net
How to write to file using FileOutputStream
How to delete objects using Hibernate?
How to implement FTP using java
How to write to file using FileWriter
how to get harddisk info using S.M.A.R.T using java
How to Store Image using JSF
Maven Dependency shift >> 1.2.0
Maven Dependency shift >> 1.2.1

Ads