Slice an array : Slice « Array « JavaScript Tutorial






<html>
<head>
<title>Using the slice() method of the Array object</title>
<script type="text/javascript" language="javascript">
<!-- //
function f(){
    var allNames = new Array("A", "B", "C", "D", "E");

    var firstB = 1;
    var firstNonB  = 2;
    var bNames = allNames.slice(firstB, firstNonB);
    var an = allNames.join(", ");
    var bn = bNames.join(", ");

    alert(an);
    alert(bn);
}
// -->
</script>
</head>
<body onload="f()">

</body>
</html>








11.27.Slice
11.27.1.Array.slice()
11.27.2.Slice an array
11.27.3.Using slice method from zArray Library