C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript handler.deleteProperty() MethodThe handler.deleteProperty() method used to remove the property entirely using the delete operator. This method returns true if the delete was successful. SyntaxdeleteProperty: function(target, property) ParametersTarget: The target object. Property: The name of the property to delete. Return valueThis method returns a Boolean value. It indicates that property successfully deletes or not. Browser Support
Example 1var proxy = new Proxy({}, { deleteProperty: function(target, prop) { document.writeln("Called: " + prop); return true; //if sucessfullt delete,return true. } });delete proxy.abc; Output: Called: abc Example 2var proxy = new Proxy({}, { deleteProperty: function(target, name) { document.write('In delete Property '); return delete target[name]; } }); delete proxy.foo; document.writeln(proxy.name); Output: In delete Property undefined Example 3var f = { bar: 'baz' } f.bar = 'baz' document.writeln('bar' in f) delete f.bar document.writeln('bar' in f) var foo = { bar: 'baz' } foo.bar = 'baz' document.writeln('bar' in foo) Output: true false true
Next TopicJavaScript handler
|