To insert an item into an array at a specific index with JavaScript, we can assign the value directly.
For instance, we write
const arr = [];
arr[0] = "Jane";
arr[1] = "Alex";
arr[2] = "Bob";
to set the entry at index 0 to 'Jane'
.
We set the entry at index 1 to 'Alex'
.
And we set the entry at index 2 to 'Bob'
.