Example 1: javascript append to array
var colors=["red","white"];
colors.push("blue");//append 'blue' to colors
Example 2: append array js
var colors= ["red","blue"];
colors.push("yellow"); //["red","blue","yellow"]
Example 3: javascript append array to array
const array1 = ['a', 'b', 'c'];
const array2 = ['d', 'e', 'f'];
const array3 = array1.concat(array2);
Example 4: add array to array javascript
// SPREAD OPERATOR
const list1 = ["pepe", "luis", "rua"];
const list2 = ["rojo", "verde", "azul"];
const newList = [...list1, ...list2];
// ["pepe", "luis", "rua", "rojo", "verde", "azul"]
Example 5: js add to array
const myArray = ['hello', 'world'];
// add an element to the end of the array
myArray.push('foo'); // ['hello', 'world', 'foo']
// add an element to the front of the array
myArray.unshift('bar'); // ['bar', 'hello', 'world', 'foo']
// add an element at an index of your choice
// the first value is the index you want to add at
// the second value is how many you want to delete (0 in this case)
// the third value is the value you want to insert
myArray.splice(2, 0, 'there'); // ['bar', 'hello', 'there', 'world', 'foo']
Example 6: javascript append array to end of array
const new_array = old_array.concat([value1[, value2[, ...[, valueN]]]])