Array concat() Method - Javascript Array

Javascript examples for Array:concat

Description

The concat() joins two or more arrays.

Parameter Values

Parameter Description
array2, array3, ..., arrayX Required. The arrays to be joined

Return Value:

An Array object, representing the joined array

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//from  w w  w . ja v  a 2s.co m
    var hege = ["a","b","c","d","e"];
    var stale = ["a","b","c","d","e"];
    var kai = ["Z"];
    var children = hege.concat(stale,kai);
    document.getElementById("demo").innerHTML = children;
}
</script>

</body>
</html>

Related Tutorials