C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript Reflect.deleteProperty() MethodThe 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:
Example 1var array1 = [1, 2, 3, 4, 5]; Reflect.deleteProperty(array1, '3'); document.writeln (array1); Output: 1,2,3,,5 Example 2const obj = {a: 1}; Object.freeze (obj ); document.writeln ( Reflect.deleteProperty ( obj , "a" ) ); Output: false Example 3const 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
|