Syntax: splice(index,len,[item]) This method will change the original array.
splice has 3 parameters, it can also be used to replace, delete or add one or several values in the array
index represents the starting subscript of the array len represents the length of replacement/deletion item represents the replaced value, if the deletion operation occurs, the item is empty
Example:
1 Delete: var arr = ['a','b','c','d'];
arr.splice(1,2);
console.log(arr);----> ;The output is ['a','d']
2 Replacement: var arr2 = ['a','b','c','d'];
arr2.splice(1,2,'ttt') ;
console.log(arr2);---->The output is ['a','ttt','d']
3. Add (make len is 0, item is the added value):
var arr = ['a','b','c','d'];
arr.splice(1,0,'ttt');
console.log(arr);-----The output is [' a','ttt','b','c','d']