How to use the shift in JavaScript

In this article we will discuss about How to use the shift() method in JavaScript.
  • 2087

This method is used to remove the first element of the Array Object in JavaScript and returns that removed element. This is the most popular method of Array Object in JavaScript. The syntax of this Method is as follows:



This method returns the single of value which was removed by it.

JavaScript Code:



    <title>JavaScript Array shift Method</title>



    <script type="text/javascript">

        var number = [101, 4, 5, 6].shift();

        document.write("Removed element is : " + number);






Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here


More Articles

© 2020 DotNetHeaven. All rights reserved.