js insert in array

JavaScript
var colors=["red","blue"];
var index=1;

//insert "white" at index 1
colors.splice(index, 0, "white");   //colors =  ["red", "white", "blue"]
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"]
var select =[2,5,8];
var filerdata=[];
for (var i = 0; i < select.length; i++) {
  filerdata.push(this.state.data.find((record) => record.id == select[i]));
}
//I have a data which is object,
//find method return me the filter data which are objects
//now with the push method I can make array of objectsvar list = ["foo", "bar"];


list.push("baz");


["foo", "bar", "baz"] // result

const months = ['Jan', 'March', 'April', 'June'];
months.splice(1, 0, 'Feb');
// inserts at index 1
console.log(months);
// expected output: Array ["Jan", "Feb", "March", "April", "June"]

months.splice(4, 1, 'May');
// replaces 1 element at index 4
console.log(months);
// expected output: Array ["Jan", "Feb", "March", "April", "May"]
Source

Also in JavaScript: