1.
Splice:Deletes the element and adds a new element, modifying the array directly, returning the arrays containing the deleted elements.
Arrayobject.splice (index,howmany,element1,....., elementx)
Index: Required,specifies where to add/remove elements from. Howmany: Must be selected,specifies how many elements should be deleted. If this parameter is not specified, all elements from index start to the end of the original array are deleted . Element1: Optional, specifies the new element to be added to the array. JS Code
- <script type ="Text/javascript">
- var arr = [1,2,3,4];
- Arr.splice (0,arr.length);
- document.write (arr); //
- </script>
2.length Properties: Sets or returns the number of elements in the array.
Arrayobject.length
length= element The last subscript +1,length value of 0 empties the elements within the array (excluding array elements that do not include an integer).The length value set is smaller than the value of the current array, the array is truncated, and the trailing element is lost. Set the lengthThe value is larger than the value of the current array, the array is incremented, the new element is added to the end of the array, and the value is undefined. JS Code
- <script type ="Text/javascript">
- var arr = [1,2,3,4];
- arr.length=0;
- document.write (arr); //
- </script>
Http://www.w3school.com.cn/js/jsref_splice.asp