The Reflect.deleteProperty(object, property) method

The Reflect.deleteProperty() method is used to delete a property of an object. It's the same as the delete operator.

This method takes two arguments--that is, the first argument is the reference to the object and the second argument is the name of the property to delete. The Reflect. deleteProperty() method returns true if it has deleted the property successfully. Otherwise, it returns false.

Here is a code example that demonstrates how to delete a property using the Reflect.deleteProperty() method:

var obj = { name: "Eden" } console.log(obj.name); //Output "Eden" Reflect.deleteProperty(obj, "name"); console.log(obj.name); //Output "undefined"

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.