insert into array js

JavaScript
arr.splice(index, 0, item);
//explanation:
inserts "item" at the specified "index",
deleting 0 other items before it// for me lol... pls don't delete!
// use splice to insert element
// arr.splice(index, numItemsToDelete, item); 
var list = ["hello", "world"]; 
list.splice( 1, 0, "bye"); 
//result
["hello", "bye", "world"]
myArray.splice(index, 0, item);let chocholates = ['Mars', 'BarOne', 'Tex'];
let chips = ['Doritos', 'Lays', 'Simba'];
let sweets = ['JellyTots'];

let snacks = [];
snacks.concat(chocholates);
// snacks will now be ['Mars', 'BarOne', 'Tex']
// Similarly if we left the snacks array empty and used the following
snacks.concat(chocolates, chips, sweets);
//This would return the snacks array with all other arrays combined together
// ['Mars', 'BarOne', 'Tex', 'Doritos', 'Lays', 'Simba', 'JellyTots']
Array.prototype.insert = function ( index, item ) {
    this.splice( index, 0, item );
};myArray.splice(index, itemsToDelete, item1ToAdd, item2ToAdd, ...)

Source

Also in JavaScript: