131
JavaScript Array concat() Method
The JavaScript array concat() method combines two or more arrays and returns a new string. This method doesn’t make any change in the original array.
Syntax
The concat() method is represented by the following syntax:
Parameter
arr1,arr2,….,arrn – It represent the arrays to be combined.
Return
A new array object that represents a joined array.
JavaScript Array concat() Method Example
Let’s see some examples of concat() method.
Example 1
Here, we will print the combination of two arrays.
Output:
C,C++,Python,Java,JavaScript,Android
Example 2
Here, we will print the combination of three arrays.
Output:
C,C++,Python,Java,JavaScript,Android,Ruby,Kotlin
Example 3
In this example, we will concat the elements directly.
Output:
C,C++,Python,Java,JavaScript,Android
Next TopicJavaScript Array