JS add list to list code example
Example 1: javascript append element to array
var colors= ["red","blue"];
colors.push("yellow");
Example 2: push only elements list into another list javascript
//Server side (nodeJs):
var a = [1,2,3];
a.push.apply(a, [4,5]);
//Client side (most browsers)
var arrayA = [1, 2];
var arrayB = [3, 4];
var newArray = arrayA.concat(arrayB);
Example 3: javascript append element to array
// initialize array
var arr = [
"Hi",
"Hello",
"Bonjour"
];
// append new value to the array
arr.push("Hola");
console.log(arr);
Example 4: javascript add item to list
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
Example 5: add item to array javascript
const arr1 = [1,2,3]
const newValue = 4
const newData = [...arr1, obj] // [1,2,3,4]
Example 6: how to add list in javascript
list=["elements"]