push array into array code example
Example 1: javascript append to array
var colors=["red","white"];
colors.push("blue");
Example 2: js array add element
array.push(element)
Example 3: pushing to an array
array = ["hello"]
array.push("world");
console.log(array);
["hello", "world"]
Example 4: add array to array javascript
const list1 = ["pepe", "luis", "rua"];
const list2 = ["rojo", "verde", "azul"];
const newList = [...list1, ...list2];
Example 5: array insertion javascript
Array.prototype.insert = function ( index, item ) {
this.splice( index, 0, item );
};
Example 6: how to push array
var numbers = [1, 2, 3, 4];
numbers.push(5);
var words = ["one", "two", "three", "four"];
words.push("five")