I have a simple object like this:
var obj = {
"option1": "item1",
"option2": "item2",
"option3": "item3"
};
For adding a new property to the object I'm using the following code:
obj[this.value] = this.innerHTML;
// this.innerHTML is used just because I'm adding the value I get from a DOM element
Is there a function that can help me remove a property from the object, that receives as a parameter the value of the key-value pair?
For example removeItem('item3');
.
Best Answer
That would probably be
delete
:FIDDLE
To do it by value, you'd do something like :
FIDDLE