Delete keys from object
Use Reflect.deleteProperty to remove a specified key from an object, rather than using the delete operator.
Reflect.deleteProperty
delete
从对象中删除指定的键
使用 Reflect.deleteProperty 从对象中删除指定的键,而不是使用 delete 操作符。
The type of elements in the array / 数组元素的类型
The object to delete keys from / 要从中删除键的对象
The keys to delete / 要删除的键
Whether any keys were deleted / 是否成功删除了键
const obj = { a: 1, b: 2 }deleteKey(obj, 'a') // truedeleteKey(obj, ['b', 'c']) // true Copy
const obj = { a: 1, b: 2 }deleteKey(obj, 'a') // truedeleteKey(obj, ['b', 'c']) // true
Delete keys from object
Use
Reflect.deletePropertyto remove a specified key from an object, rather than using thedeleteoperator.从对象中删除指定的键
使用
Reflect.deleteProperty从对象中删除指定的键,而不是使用delete操作符。