by @kodeazy
How to remove the first element of an array and return it in javascript?
var arry = ['element_1', 'element_2', 'element_3', 'element_4', 'element_5','element_6']
- I have an array of elements as above.
-
To remove th first element of the array we use the
shift
method as below.var first = arry.shift(); console.log("first element is:"+first); console
Output
["element_2", "element_3", "element_4", "element_5", "element_6"]