You would like to remove a given property from a javascript object. Here is a simple example of how you could do it :
You have defined an object similar to the following:
let oneObject = { “Prop1”: “Val1”, “Prop2”: “Val2” };
And you would like to remove one property, say “Prop1”, from the object oneObject so that it becomes defined as follows :
oneObject = { “Prop2”: “Val2” };
Read: How to remove duplicates from Arrays in Javascript
In order to do this, simply write the following code :
delete oneObject.Prop1; //remove property from object javascript
Read: How to check if a string contains another string in JavaScript
Or, if you like write also:
delete oneObject[‘Prop1’]; //Again using javascript delete
Read: Should You Learn JavaScript, Advice for Newbie Web Developers
If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.