Unshift
The unshift
method adds new elements sequentially to the start, or front of the array. For example.
let array = [0, 5, 10];
array.unshift(-5);
// RESULT: array = [-5 , 0, 5, 10];
The unshift()
method overwrites the original array.
Last updated
Was this helpful?