add to an array in js code example
Example 1: js array add element
array.push(element)
Example 2: javascript pushing to an array
some_array = ["John", "Sally"];
some_array.push("Mike");
console.log(some_array); //output will be =>
["John", "Sally", "Mike"]
Example 3: javascript array push
var fruits = [ "Orange", "Apple", "Mango"];
fruits.push("Banana");
Example 4: add item to array javascript
const arr1 = [1,2,3]
const newValue = 4
const newData = [...arr1, obj] // [1,2,3,4]