Introduction
In JavaScript, there are situations when we wish to remove a property from a JavaScript object.
In this post, we'll present how to remove a property from an object in JS.
How to remove a property from a JavaScript object
To remove a property from an object we use the JavaScript delete
operator:
var obj = {
"attr1": "value1",
"attr2": "value2",
"attr3": "value3"
};
delete obj.attr1;
console.log(obj); // { attr2: "value2", attr3: "value3" }
Conclusion
To remove a property from an object in JavaScript we can use the delete
operator.
In ES6, we can use destructuring feature to remove a property from an object.
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}