javascript concat() method
Translation results:
Function; merge arrays; merge multiple strings; contact us
javascript concat() methodsyntax
How to use the concat method?
The concat() method in JavaScript can be used to concatenate two or more arrays to create a new array, and can also be used to concatenate strings.
Function: Used to connect two or more arrays. This method does not modify the existing array, but simply returns a copy of the concatenated array.
Syntax: arrayObject.concat(arrayX,arrayX,...,arrayX)
Parameters: arrayX Required. This parameter can be a specific value or an array object. Can be any number.
Return:Return 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.
javascript concat() methodexample
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script type="text/javascript"> var a = [1,2,3]; document.write(a.concat(4,5)); </script> </body> </html>
Run instance »
Click the "Run instance" button to view the online instance