In JavaScript, you can use the delete operator to delete a property in an object:
The limitation of this property deletion operation is that the delete operator can only delete all the properties of the object itself, and cannot delete the properties inherited from the prototype object. If you want to delete the property in the prototype object, you must explicitly obtain the prototype object and then perform the operation in the prototype object:
If a property in a prototype object is deleted, all objects that inherit from the prototype object will be affected.
For the return value of delete operation, JavaScript follows the following rules:
1. If the delete operation is successful, return true.
2. If the delete operation has no effect (for example, the property to be deleted does not exist), it will also return true.
3. If you want to delete a property whose configurable attribute is false, a TypeError error will be reported in strict mode, and false will be returned in non-strict mode.
If the delete operator acts on the property of the global object, then in non-strict mode, the global object in the code can be omitted:
It should be noted that in strict mode, the above writing method will throw a SyntaxError.