TypeScript | Array concat() Method

The Array.concat() is an inbuilt TypeScript function which is used to merge two or more arrays together. 
Syntax:

array.concat(value1, value2, ..., valueN)

Parameter: This method accepts a single parameter multiple time as mentioned above and described below: 

  • valueN : These parameters are arrays and/or values to concatenate.

Return Value: This method returns the new array. 
Below examples illustrate the Array concat() method in TypeScript
Example 1: 

JavaScript

filter_none

edit
close

play_arrow

link
brightness_4
code

<script>
    // Driver code
    var num1 = [11, 12, 13];
    var num2 = [14, 15, 16];
    var num3 = [17, 18, 19]; 
  
    // use of String concat() Method
    console.log(num1.concat(num2, num3)); 
</script>

chevron_right


Output: 



[ 11, 12, 13, 14, 15, 16, 17, 18, 19 ]

Example 2: 

JavaScript

filter_none

edit
close

play_arrow

link
brightness_4
code

<script>
    // Driver code
    var num1 = ['a', 'b', 'c'];
  
    // use of String concat() Method
    console.log(num1.concat(1, [2, 3])); 
</script>

chevron_right


Output: 

[ 'a', 'b', 'c', '1,2,3' ]

full-stack-img

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.