JavaScript concat() method
JavaScript concat() Method
JavaScript Array Object
Instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网</title> </head> <body> <script> var hege = ["Cecilie", "Lone"]; var stale = ["Emil", "Tobias", "Linus"]; var kai = ["Robin"]; var children = hege.concat(stale,kai); document.write(children); </script> </body> </html>
Run instance»
Click the "Run instance" button to view the online instance
Definition and usage
The concat() method is used to concatenate two or more arrays.
This method does not change the existing array, but only returns a copy of the connected array.
Browser support
All major browsers support the concat() attribute.
Syntax
##array1.concat(array2,array3,...,arrayX)
Description | |
---|---|
, array3, ..., arrayXRequired. This parameter can be a specific value or an array object. Can be any number. |
Description | |
---|---|
Returns a new array. The array is generated by adding all arrayX parameters to arrayObject. If the argument to concat() is an array, then the elements in the array are added, not the array. |
1.2 |
---|
JavaScript Array Object