The Splice method in 1:js
Splice (Index,len,[item]) Comment: The method changes the original array.
The splice has 3 parameters, which can also be used to replace/delete/Add one or more values within an array
Index: Array start subscript len: replace/Delete length item: Replace value, delete action if item is empty
such as: arr = [' A ', ' B ', ' C ', ' d ']
Delete----item is not set
Arr.splice (//[' A ', ' C ', ' d ') deletes a value starting from subscript 1, length 1, Len set 1, and if 0, the array is unchanged
Arr.splice (//[' A ', ' d ') removes a value from the starting subscript of 1, length 2, and Len sets 2
Replace----item for the replacement value
Arr.splice ("TTT")//[' a ', ' ttt ', ' C ', ' d '] replace the starting subscript with 1, a value of length 1 for ' TTT ', Len set 1
Arr.splice ("TTT")//[' a ', ' ttt ', ' d '] replace the starting subscript with 1, length 2 of two values for ' TTT ', Len set 1
Add----len set to 0,item for added value
Arr.splice (1,0, ' TTT ')//[' a ', ' ttt ', ' B ', ' C ', ' d '] means adding a ' ttt ' at subscript 1
It looks like splice is the most convenient.
2:delete Delete Removes the element from the array, it will set the value of the subscript to undefined, and the length of the array will not change
such as: delete arr[1]//[' A ',, ' C ', ' d '] in the middle of the two comma, the length of the array is unchanged, there is a undefined
JS a few ways to delete an item or items in an array