TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

JavaScript handler deleteProperty() Method

JavaScript handler deleteProperty() Method with examples on javascript handler, javascript methods, javascript tutorial, apply(), construct(), defineProperty(), deleteProperty(), get(), setPrototypeOf(), set(), ownKeys(), isExtensible() etc.

<< Back to JAVASCRIPT

JavaScript handler.deleteProperty() Method

The handler.deleteProperty() method used to remove the property entirely using the delete operator. This method returns true if the delete was successful.

Syntax

deleteProperty: function(target, property)

Parameters

Target: The target object.

Property: The name of the property to delete.

Return value

This method returns a Boolean value. It indicates that property successfully deletes or not.

Browser Support

Chrome 49
Edge 12
Firefox 18
Opera 36

Example 1

var proxy = new Proxy({}, {
  deleteProperty: function(target, prop) {
    document.writeln("Called: " + prop);
    return true;
    //if sucessfullt delete,return true.
  }
});delete proxy.abc;
Test it Now

Output:

Called: abc

Example 2

var proxy = new Proxy({}, {
  deleteProperty: function(target, name) {
    document.write('In delete Property  ');
 
    return delete target[name];
  }
});
delete proxy.foo;
document.writeln(proxy.name);
Test it Now

Output:

In delete Property undefined 

Example 3

var 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)
Test it Now

Output:

true false true

Next TopicJavaScript handler




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf