let arr1 = [0, 1, 2]; let arr2 = [3, 5, 7]; let primes = arr1.concat(arr2); // > [0, 1, 2, 3, 5, 7]
var hege = ["Cecilie", "Lone"]; var stale = ["Emil", "Tobias", "Linus"]; var children = hege.concat(stale);
const array1 = ["Vijendra","Singh"]; const array2 = ["Singh", "Shakya"]; const array3 = [...array1, ...array2];
const letters = ['a', 'b', 'c']; const numbers = [1, 2, 3]; letters.concat(numbers); // result in ['a', 'b', 'c', 1, 2, 3]
//ES6 using the spread operator const itemsA = [ 'Lightsaber', 'Mockingjay pin', 'Box of chocolates' ]; const itemsB = [ 'Ghost trap', 'The One Ring', 'DeLorean' ] const allItems = [ ...itemsA, ...itemsB ];