TheDeveloperBlog.com

Home | Contact Us

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

JavaScript Reflect deleteProperty() Method

JavaScript Reflect deleteProperty() Method with examples on javascript reflect methods, apply() construct(), defineProperty() method, deleteProperty(), get(), getOwnPropertyDescriptor(), getPrototypeOf(), has(), isExtensible(), ownKeys(), setPrototypeOf() etc.

<< Back to JAVASCRIPT

JavaScript Reflect.deleteProperty() Method

The Reflect.deleteProperty() method allows to delete a property on an object. If the method returns true, that means deleting the property is successful. Otherwise, it returns false.

Syntax:

Reflect.deleteProperty(target, propertyKey)

Parameters:

target: It is the target object on which to delete the property.

propertyKey: It is the name of the property to be deleted.

Return value:

A Boolean represents that the property was successfully deleted or not.

Exceptions:

A TypeError, if the target is not an Object.

Browser Support:

Chrome 49
Edge 12
Firefox 42
Opera 36

Example 1

var array1 = [1, 2, 3, 4, 5];
Reflect.deleteProperty(array1, '3');
document.writeln (array1);

Output:

1,2,3,,5

Example 2

const obj = {a: 1};
Object.freeze (obj );
document.writeln ( Reflect.deleteProperty ( obj , "a" ) ); 

Output:

false 

Example 3

const obj = {a: 1, b:6, c:5};
document.writeln ( Reflect.deleteProperty ( obj , "a" ) );
document.writeln ( Reflect.deleteProperty ( obj , "b" ) );
document.writeln ( Reflect.deleteProperty ( obj , "c" ) );

Output:

 true true true
Next TopicJavaScript Reflect




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