Tag: color element false HTTP font position FFFFFF parameter ice
On the use and difference of Delete () and splice () in the array method
Deletearr[i] deletes the item of the specified index of the array, or the item will occupy the position of the original array when it is deleted, except that the value of the position becomes undefined; Delete also has a return value, which returns a value of True when it can be deleted. In addition, delete can delete a property of an object, but cannot delete the variable defined by VAR, at which time the return value is false;
var arr1 = [5, 4, 3, 2, 1, 9 ]; Console.log (arr1); Delete arr1[1 ]); Console.log (ARR1);
The results are printed as follows:
Two.splice (Index,length,[item]), the parentheses contain three parameters, index is the starting position of the indexes, length is required to delete the number of array elements, [item], for the deletion after the replacement of the elements, note that When only the delete operation is performed, the value of [item] is empty and can be not written at this time; The return value is the corresponding value of the deletion;
var arr1 = [5, 4, 3, 2, 1, 9 ]; Console.log (arr1); 0, 1 )); Console.log (ARR1);
The results are printed as follows:
If you replace the deleted value with another:
On the use and difference of Delete () and splice () in the array method