9951 explained code solutions for 126 technologies


javascriptAdd new element at the beginning of an array


var arr = [2, 3, 4, 5];
arr.unshift(1);ctrl + c
var arr

declare array to insert value to

arr.unshift

will insert new value at the beginning of arr

(1)

value to insert (1 in this case)