how to append to an 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: javscript append item from array
let foo = ['oop','plop','copo'];
foo.push("plop");
Example 4: add item to array javascript
const arr1 = [1,2,3]
const newValue = 4
const newData = [...arr1, obj]
Example 5: javascript append to array
arr = [1, 2, 3, 4]
arr.push(5)
arr.unshift(0)