![]() |
VOOZH | about |
JavaScript handler.deleteProperty() method in JavaScript is a trap for the delete operator. This method returns the boolean value if the delete was successful.
Syntax:
const p = new Proxy(target, {
deleteProperty: function(target, property) {
}
});
Parameters: This method accepts two parameters as mentioned above and described below:
Return value: This method returns a Boolean value that indicates whether the property was successfully deleted.
Below examples illustrate the handler.deleteProperty() method in JavaScript:
Example 1: In this example, we will trap a delete operator using the handler.deleteProperty() method in JavaScript.
Output:
"Green" "Color is property which is removed" undefined true false
Example 2: In this example, we will trap a delete operator using the handler.deleteProperty() method in JavaScript.
Output:
true "prop1 property is removed." true false "prop1 property is not removed." false
Supported Browsers: The browsers supported by the handler.deleteProperty() method are listed below:
We have a complete list of Javascript Proxy/handler methods, to check those go through the Javascript Proxy/handler Reference article.