insert an array into another array javascript code example
Example 1: assign array to another array javascript
var ar = ["apple","banana","canaple"];
var bar = Array.from(ar);
alert(bar[1]);
Example 2: javascript adding an array to an array
let chocholates = ['Mars', 'BarOne', 'Tex'];
let chips = ['Doritos', 'Lays', 'Simba'];
let sweets = ['JellyTots'];
let snacks = [];
snacks.concat(chocholates);
snacks.concat(chocolates, chips, sweets);
Example 3: javascript push all elements of array to another array
var arrayA = [1, 2];
var arrayB = [3, 4];
var newArray = arrayA.concat(arrayB);
Example 4: javascript add array to array at index
a1.splice(2, 0, ...a2);