1.
<script> /*splice (start,len) deletes several items from that position */ var arr = [1,2,3,4,5,6]; var removed = Arr.splice (2,3); Alert (arr);//[1,2,6]//Remove 3 alert (removed)//[3,4,5] /*splice (Start,len,...) from the position subscript 2 When Len is 0, insert */ var arr2 = [1,2,3,4,5]; var removed = Arr2.splice (2,0, "a", "B", "C");//Remove 0 from the subscript 2 and insert "A", "B", "C" var removed = Arr2.splice (2,0,["A", "B", "C"]); Remove 0 from the subscript 2 and insert ["A", "B", "C"] alert (ARR2),//["A", "B", "C", 3,4,5] alert (removed = = undefined);//null /*splice (Start,len,...), when Len is not 0 */ var arr3 = ["Hello", "World", "JS", "Java"]; var removed = Arr3.splice (1,2,[1,2,3,4,5,6]);//Remove 2 elements from the subscript 1 and add the array to alert (ARR3);//["Hello", "Java", 1,2,3,4,5,6] alert (removed);//["World", "JS" </script>
Intelligent Society-The Splice