Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

A better way to concatenate arrays

let arr1 = [0, 1, 2];
let arr2 = [3, 4, 5];

arr1 = [...arr1, ...arr2];
//  arr1 is now [0, 1, 2, 3, 4, 5]
// Note: Not to use const otherwise, it will give TypeError (invalid assignment)
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #A #concatenate #arrays
ADD COMMENT
Topic
Name
9+3 =