Removes a specified property from an object.
JSBool JS_DeleteProperty(JSContext *cx, JSObject *obj, const char *name); JSBool JS_DeletePropertyById(JSContext *cx, JSObject *obj, jsid id);
| || ||Pointer to a JS context from which to derive runtime information. Requires request. In a |
| || ||Object from which to delete a property.|
| || ||Name of the property to delete.|
JS_DeleteProperty removes a specified property,
name, from an object,
JS_DeletePropertyById is the same but takes a
jsid for the property name. These functions are identical to
JS_DeletePropertyById2 except that they do not have an out parameter.
First, a property lookup is performed. Then one of the following cases applies:
objhas no property with the given
id, or if
objinherits the specified property from its prototype, then
JSClass.delPropertyhook is called. No property is deleted, but this is not an error.
objhas the specified property but it is permanent, nothing happens. No property is deleted, but this is not an error.
objhas a non-permanent own property with the given
id. In this case,
JSClass.delPropertyhook is called. If the hook returns
JS_FALSE, the error is propagated. Otherwise, if
objis sealed, an error is raised. Otherwise, the property is removed.
These functions return
JS_TRUE on success, regardless of whether a property was actually deleted, and
JS_FALSE on error or exception.
Internally, property deletion is implemented by the
To remove all properties from an object, call