Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript combining arrays

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

let combarr = [].concat(arr1); //define new variable, empty array then concatenating arr1 to it
combarr = combarr.concat(arr2); //combarr = itself, then concatenating arr2 to the end
console.log(combarr); //Expected output: ['1','2','3','4']
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #javascript #combining #arrays
ADD COMMENT
Topic
Name
4+2 =