JavaScript concat() method


JavaScript concat() Method

Array 对象参考手册 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

QQ截图20161108165429.png

All major browsers support the concat() attribute.


Syntax

##array1.concat(array2,array3,...,arrayX)
ParameterValues

##Parameterarray2Return value
Description
, array3, ..., arrayXRequired. This parameter can be a specific value or an array object. Can be any number.

TypeArray objectTechnical Details
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.

JavaScript Version:
1.2


JavaScript Array Object

Array 对象参考手册