What is unshift method in JavaScript?

What is unshift method in JavaScript?

1 Like

Unshift method in JavaScript works on array to adds one or more elements to the beginning of the array and returns the new length of the array.

It is not a pure function as it changes the length of the array directly.

syntax: array.unshift(item1, item2, …, itemX)