How to Remove a Property From an Object in JavaScript
An object is a dynamic collection of key-value pairs. Here is such an object.
const dto = {
message : 'Hi',
priority: 1
}
A property can be deleted using the delete operator.
When the property key is a valid identifier we can use the dot notation to access and delete the property.
delete dto.priority;console.log(dto);
//{message: "Hi"}
When the key is stored in a variable we can use the bracket notation to access and delete the property. Consider t...
Published on April 19, 2021 03:46