Visit Mozilla.org

JS DeleteProperty2

From MDC

(Redirected from JS DeleteUCProperty2)

Removes a specified property from an object.

Contents

[edit] Syntax

JSBool JS_DeleteProperty2(JSContext *cx, JSObject *obj,
    const char *name, jsval *rval);

JSBool JS_DeleteUCProperty2(JSContext *cx, JSObject *obj,
    const jschar *name, size_t namelen, jsval *rval);
Name Type Description
cx JSContext * Pointer to a JS context from which to derive runtime information.

Requires request. (In a JS_THREADSAFE build, the caller must be in a request on this JSContext.)

obj JSObject * Object from which to delete a property.
name const char * or const jschar * Name of the property to delete.
namelen size_t (only in JS_DeleteUCProperty2) The length of name in characters; or -1 to indicate that name is null-terminated.
rval jsval * Out parameter. *rval receives the stored value of the deleted property.

[edit] Description

JS_DeleteProperty2 removes a specified property, name, from an object, obj, and assigns the final stored value of the deleted property to *rval. If an object references a property belonging to a prototype, the property is removed from the object, but not from the prototype. If deletion is successful, JS_DeleteProperty2 returns JS_TRUE. Otherwise it returns JS_FALSE.

JS_DeleteUCProperty2 is the Unicode version of the function.

[edit] Notes

Per the ECMA standard, these functions remove read-only properties from objects as long as those properties are not also permanent.

For JavaScript 1.2 and earlier, if JS_DeleteProperty2 or JS_DeleteUCProperty2 fails because the property to be deleted is permanent, it reports the error before returning JS_FALSE. For JavaScript 1.3, the attempt is silently ignored. In both these cases, *rval will receive the stored value of the property that was not deleted.

To remove all properties from an object, call JS_ClearScope.

[edit] See Also

LXR ID Search for JS_DeleteProperty2
LXR ID Search for JS_DeleteUCProperty2

JS_ClearScope, JS_DefineProperty, JS_DefinePropertyWithTinyId, JS_DeleteProperty, JS_GetProperty, JS_LookupProperty, JS_PropertyStub, JS_SetProperty