9951 explained code solutions for 126 technologies

javascriptInsert an item to an array at a certain index

var arr = ['value1', 'value2'];
arr.splice(1, 0, 'new value');ctrl + c
var arr

declare test array to insert new value into


inserts a new value into an array


index to insert new value at (starts at 0, so we will insert our value at second position)


do not delete any values from old array

'new value'

what value to insert