add item from array javascript code example
Example 1: javascript insert item into array
var colors=["red","blue"];
var index=1;
colors.splice(index, 0, "white");
Example 2: js array add element
array.push(element)
Example 3: js add item to array
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
Example 4: javscript append item from array
let foo = ['oop','plop','copo'];
foo.push("plop");
Example 5: js push array
array.push(element_to_push);
Example 6: javascript add items to array
objects = [];
objects.push("you can add a string,number,boolean,etc");
objects.push({variable1 : value, variable2 : value);