pushing array into array javascript 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: pushing to an array

array = ["hello"]
array.push("world");

console.log(array);
//output =>
["hello", "world"]

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'); // 3
arr; // ["foo", "bar", "baz"]

Example 6: add item to array javascript

const arr1 = [1,2,3]
const newValue = 4
const newData = [...arr1, obj] // [1,2,3,4]