Actual success in copying an array using concat() : Concat « Array « JavaScript Tutorial






<html>
<head>
<title>Actual success in copying an array using concat()</title>
<script type="text/javascript" language="javascript">
<!-- //
function CopyArray(){
var myArray = new Array(1,2,3);
var emptyArray = new Array();

var myCopy  = myArray.concat(emptyArray);
    myArray[0] = 10;
    myArray[1] = 20;
    myArray[2] = 30;
var ma = myArray.join(", ");
var mc = myCopy.join(", ");
alert(ma);
alert(mc);
}
// -->
</script>
</head>
<body onload="CopyArray()">

</body>
</html>








11.9.Concat
11.9.1.Array.concat()
11.9.2.Actual success in copying an array using concat()
11.9.3.Using concat() method to combine two arrays