1arr.splice(index, 0, item);
2//explanation:
3inserts "item" at the specified "index",
4deleting 0 other items before it
1var colors=["red","blue"];
2var index=1;
3
4//insert "white" at index 1
5colors.splice(index, 0, "white"); //colors = ["red", "white", "blue"]
6
1// for me lol... pls don't delete!
2// use splice to insert element
3// arr.splice(index, numItemsToDelete, item);
4var list = ["hello", "world"];
5list.splice( 1, 0, "bye");
6//result
7["hello", "bye", "world"]
8
1Array.prototype.insert = function ( index, item ) {
2 this.splice( index, 0, item );
3};