ES6 - Array Method shift()



shift()method removes the first element from an array and returns that element.

Syntax

array.shift();    

Return Value

Returns the removed single value of the array.

Example

var arr = [10, 1, 2, 3].shift(); 
console.log("Shifted value is : " + arr )   

Output

Shifted value is : 10 
Advertisements