javascript add an array to an array code example
Example 1: javascript append to array
var colors=["red","white"];
colors.push("blue");//append 'blue' to colors
Example 2: js array add element
array.push(element)
Example 3: append array js
var colors= ["red","blue"];
colors.push("yellow"); //["red","blue","yellow"]
Example 4: how to add a new item in an array in javascript
let array = ["Chicago", "Los Angeles", "Calgary", "Seattle", ]
// print the array
console.log(array)
//Adding a new item in an array without touching the actual array
array.push('New Item') < variable_name > .push( < What you want to add > )
//How many items does the array have?
console.log("This array has", array.length, "things in it")
Example 5: javascript append array to end of array
const new_array = old_array.concat([value1[, value2[, ...[, valueN]]]])
Example 6: nodejs add to array
var colors=["red","white"];
colors.push("blue");//append 'blue' to colors