Description
The concat() method is used to join two or more arrays.
This method has the form:
array.concat(a1,a2,...,aX)
Parameter | Description |
---|---|
a1,a2,...,aX | (required) The arrays to be joined |
Note: This method does not change the existing arrays, it only returns a copy of the joined arrays.
Return Value
An Array containing all the values of the arrays
Examples
The following example shows the basic use of this method.
<script>
var cols1 = [ "Cyan", "Magenta" ];
var cols2 = [ "Yellow", "Black" ];
document.write(cols1.concat(cols2));
</script>
This produces the following result:
Browser Support
Firefox | IE | Chrome | Opera | Safari |
---|---|---|---|---|