add value array javascript code example
Example 1: javascript append to array
var colors=["red","white"];
colors.push("blue");
Example 2: javascript append element to array
var colors= ["red","blue"];
colors.push("yellow");
Example 3: javascript pushing to an array
some_array = ["John", "Sally"];
some_array.push("Mike");
console.log(some_array);
["John", "Sally", "Mike"]
Example 4: add value to array javascript
var fruits = ["222", "vvvv", "eee", "eeee"];
fruits.push("Kiwi");
Example 5: array push
arr.push([element1[, ...[, elementN]]])
Example 6: add item to array javascript
const arr1 = [1,2,3]
const newValue = 4
const newData = [...arr1, obj]