1. Delete the specified subscript element from the JS array
splice method——Array.splice(index,n)
Parameter semantic understanding: delete the n elements starting from the subscript index. (the following elements will move forward)
Note: splice will directly change the original array
let arr=['a','b','c','d'];
arr.splice(2,1);
console.log(arr); // ['a','b','d']
let arr=['a','b','c','d'];
arr.splice(0,4);
console.log(arr); // []
let arr=['a','b','c','d'];
arr.splice(0,2);
console.log(arr); // ['c','d']
2. JS deletes the specified element of the object
var student = {
name: '小明',
sex: '男',
age: 18
}
delete student.name;
console.log(student, 'student')
Reference: https://jingyan.baidu.com/article/ca2d939d00c8c8aa6c31cef4.html