Using the splice() method of the Array object : Splice « Array « JavaScript Tutorial






<html>
<head>
<title>Using the splice() method of the Array object</title>
<script type="text/javascript" language="javascript">
<!-- //
function SpliceArray(){
    var x = new Array("a", "b", "c", "d");
    var xj = x.join(", ");

    document.write("<P>The original array x contains: " + xj + " </p>");
    document.write("<P>The length of the original array x  is: " + x.length + " </p>");
    var y = x.splice(1,1);
    var yj = y.join(", ");

    document.write("<P>The array  y after using splice() contains: " + yj + " </p>");
    document.write("<P>The length of the array  y after splice() is: " + y.length + " </p>");

    var xj = x.join(", ");
    document.write("<P>The original array  x now contains: " + xj + " </p>");
    document.write("<P>The length of the original array x  is now: " + x.length + " </p>");
}
// -->
</script>
</head>
<body onload="SpliceArray()">

</body>
</html>








11.30.Splice
11.30.1.Array.splice()
11.30.2.Using the splice() method of the Array object
11.30.3.Using the splice() method to replace elements
11.30.4.Using the splice() method to insert elements
11.30.5.Using splice method from zArray Library
11.30.6.Using splice method from zArray Library 2