Remove First Array Element in JavaScript and Return It



To remove first array element, use the JavaScript shift() method. JavaScript array shift() method removes the first element from an array and returns that element.

Example

You can try to run the following code to remove first array element and return it −

Live Demo


   
      JavaScript Array shift Method
   
   
      
   

Output

Removed first element is : 30
Updated on: 2020-06-18T09:17:42+05:30

237 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements