Asked by Daniyal Mill · · 2 answers
Objects in JavaScript can be thought of as maps between keys and values. The delete operator is used to remove these keys.
var obj = {
myProperty: 1
}
console.log(obj.hasOwnProperty('myProperty')) // true
delete obj.myProperty
console.log(obj.hasOwnProperty('myProperty')) // false
Or, you can use object destructuring, an ECMAScript 6 feature, it's as simple as:
let myObject = {
"item1": "value",
"item2": "value",
"item3": "value"
};
({ item1, ...myObject } = myObject);
console.log(myObject);
0
0