What is array concat in JavaScript

In this article, I am going to explain array concat method.
  • 1874

Array concat method in JavaScript

The array concat() in JavaScript concatenate or combined two or more array and returning a new array.

Syntax of concat method


Parameters in array concat method:

  • array

    Array object to which all other arrays are concateated.

  • Value

    value are array item to add to the end of array.

Return value of concat method

Concat method returns the length of the array.

Example of array concat()


<!DOCTYPE html>



<title>JavaScript array concat() example</title>

<script type="text/javascript">

    var firstArray = new Array(2);

    firstArray[0] = "Mcn";

    firstArray[1] = "soluation";

    var secondArray = new Array(2);

    secondArray[0] = "Private";

    secondArray[1] = "Limited";

    var finalArray = firstArray.concat(secondArray);

    document.write("<b>First array is</b>=>" + firstArray + "<br> ");

    document.write("<b>Second array is</b> =>" + secondArray + "<br> ");

    document.write("<b>Concatenated array is</b> =>" + finalArray + "<br> ");






First array is=>Mcn,soluation
Second array is =>Private,Limited
Concatenated array is =>Mcn,soluation,Private,Limited

Ask Your Question 
Got a programming related question? You may want to post your question here


More Articles

© 2020 DotNetHeaven. All rights reserved.