<html>
<head>
<title>Using concat() method to combine two arrays</title>
<script type="text/javascript" language="javascript">
<!-- //
function ConcatArrays(){
var firstArray = new Array(1,2,3);
var secondArray = new Array(4,5,6);
var combinedArray = firstArray.concat(secondArray);
var fa = firstArray.join(", ");
var sa = secondArray.join(", ");
var ca = combinedArray.join(", ");
document.write("<P>The first array contains: <b>" + fa + " </b></p>");
document.write("The second array contains: <b>" + sa + " </b></p>");
document.write("The combined array contains: <b>" + ca + " </b></p>");
document.write("The combined array length is: <b>" + combinedArray.length + "
</b></p>");
}
// -->
</script>
</head>
<body onload="ConcatArrays()">
</body>
</html>
|