方法一:不改变原来对象
let item = {
name:
‘张三‘
,
age:
‘18‘
,
gender:
‘男‘
};
console.log(item)
// {age: "18",gender: "男",name: "张三"}
let { age,...params } = item;
console.log(item)
// {age: "18",gender: "男",name: "张三"}
console.log(
typeof
params.age)
// undefined
console.log(params)
// {gender: "男",name: "张三"}
方法二:
直接改变对象
let item1 = {
name:
‘张三‘
,
age:
‘18‘
,
gender:
‘男‘
};
console.log(item1)
// {age: "18",gender: "男",name: "张三"}
delete
item1.name;
console.log(
typeof
item1.name)
// undefined
console.log(item1)
// // {age: "18",gender: "男"}