To prepend a value to an array with JavaScript, we call the unshift
method.
For instance, we write
a.slice().unshift(0);
to call a.slice
to make copy of the a
array.
And then we call unshift
on the copied array to prepend 0 into the array.