JavaScript concat() Method : Array Object
Description
The concat() method is used to join two or more arrays. Concat does not alter the original arrays, it returns a copy of the same elements combined from the original arrays.
Version
Implemented in JavaScript 1.2
Syntax
concat(arrayname1, arrayname2, ..., arraynameN)
Parameter
arrayname1, arrayname2, ..., arraynameN : Arrays to be joined to an array.
Example -1:
In the following web document two arrays arrayname1 and arrayname2 with single element have joined by concat() method.
HTML Code
JS Code
View the example in the browser
Practice the example online
JavaScript concat() method example on two arraysExample -2:
In the following web document three arrays array1, array2 and array3 with multiple elements have joined by concat() method.
HTML Code
JS Code
View the example in the browser
Practice the example online
JavaScript concat() method example on multiple arraysSee also:
JavaScript Core objects, methods, properties.
Previous: JavaScript prototype Property: Array Object
Next:
JavaScript join() Method: Array Object
Test your Programming skills with w3resource's quiz.