node add to array code example
Example 1: javascript append to array
var colors=["red","white"];
colors.push("blue");
Example 2: nodejs add element to array
var array = [];
array.push(element)
console.log(array);
Example 3: javascript add items to array
objects = [];
objects.push("you can add a string,number,boolean,etc");
objects.push({variable1 : value, variable2 : value);
Example 4: javascript push all elements of array to another array
var arrayA = [1, 2];
var arrayB = [3, 4];
var newArray = arrayA.concat(arrayB);
Example 5: js add to array
let arr = [1, 2, 3, 4];
arr = [...arr, 5, 6, 7];
console.log(arr);
Example 6: add item to array javascript
const arr1 = [1,2,3]
const newValue = 4
const newData = [...arr1, obj]