adding items to an array javascript code example
Example 1: js push array
var array = [];
var element = "anything you want in the array";
array.push(element);
Example 2: add array to array javascript
const list1 = ["pepe", "luis", "rua"];
const list2 = ["rojo", "verde", "azul"];
const newList = [...list1, ...list2];
Example 3: js add to array
const myArray = ['hello', 'world'];
myArray.push('foo');
myArray.unshift('bar');
myArray.splice(2, 0, 'there');
Example 4: js add array items to array
var arrayA = [1, 2];
var arrayB = [3, 4];
var newArray = arrayA.concat(arrayB);