JS Tutorial

Function Reference

Method Reference

  • JS String
  • JS Array
  • JavaScript Array

    Concatenate Arrays in JS

    Example 1- ES5

    let array1 = [4,5,6];
    let array2 = [7,8];
    var array = array1.concat(array2);
    
    console.log(array); //Output : [4, 5, 6, 7, 8]
    

    Example 2- ES6

    Arrays Concatenate in JavaScript using spread operator

    let array1 = [4,5,6];
    let array2 = [7,8,9];
    var array = [...array1,...array2];
    console.log(array); //Output : [4, 5, 6, 7, 8]