add item to javascript array code example
Example 1: javascript insert item into array
var colors=["red","blue"];
var index=1;
colors.splice(index, 0, "white");
Example 2: add item to list javascript
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
Example 3: javascript append element to array
var arr = [
"Hi",
"Hello",
"Bonjour"
];
arr.push("Hola");
console.log(arr);
Example 4: pushing element in array in javascript
array = ["hello"]
array.push("world");
Example 5: js array push
const arr = ["foo", "bar"];
arr.push('baz');
arr;
Example 6: nodejs add to array
var colors=["red","white"];
colors.push("blue");