Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at


Obsolete since JSAPI 36
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

JSNewResolveOp is the type of the JSClass.resolve callback when the JSCLASS_NEW_RESOLVE bit is set in the JSClass.flags field.


typedef bool
(* JSNewResolveOp)(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
                   JS::MutableHandleObject objp);
Name Type Description
cx JSContext * Pointer to the JS context in which the property access is taking place.
obj JS::HandleObject Pointer to the object whose properties are being accessed.
id JS::HandleId Name or index of the property being accessed.
flags uint32_t Obsolete since JSAPI 31 Flags giving contextual information about the ongoing property access.
objp JS::MutableHandleObject Out parameter. On success, the resolve hook must set *objp to the object in which the property has been defined, or NULL if it was not defined.


Like JSResolveOp, but flags provide contextual information about the property access.

On success, the callback must set the *objp out parameter to null if id was not resolved; or non-null, referring to obj or one of its prototypes, if id was resolved; and return JS_TRUE. On failure, it must return JS_FALSE.

This hook instead of JSResolveOp is called via the JSClass.resolve member if JSCLASS_NEW_RESOLVE is set in JSClass.flags.

Setting JSCLASS_NEW_RESOLVE and JSCLASS_NEW_RESOLVE_GETS_START further extends this hook by passing in the starting object on the prototype chain via *objp. Thus a resolve hook implementation may define the property id being resolved in the object in which the id was first sought, rather than in a prototype object whose class led to the resolve hook being called.

When using JSCLASS_NEW_RESOLVE_GETS_START, the resolve hook must therefore null *objp to signify "not resolved". With only JSCLASS_NEW_RESOLVE and no JSCLASS_NEW_RESOLVE_GETS_START, the hook can assume *objp is null on entry. This is not good practice, but enough existing hook implementations count on it that we can't break compatibility by passing the starting object in *objp without a new JSClass flag.


The flags argument is the logical OR of zero or more of the following flags. The flags describe what kind of property access triggered the resolve callback. (The same flags are used in JS_LookupPropertyWithFlags.)

The property access uses the . or [] operator: or obj[id], not id.
The property appears on the left-hand side of an assignment.
The property is being used in code like "if (o.p)...", or a similar idiom where the apparent purpose of the property access is to detect whether the property exists.  (This flag has been replaced with the JSCLASS_EMULATES_UNDEFINED mechanism.)
The property is being declared in a var, const, or function declaration.
JSRESOLVE_CLASSNAME Obsolete since JavaScript 1.8.8
class name used when constructing.
JSRESOLVE_WITH Obsolete since JavaScript 1.8.8
The lookup is occurring for a name evaluated inside a with statement.

See Also

Document Tags and Contributors

 Contributors to this page: arai, evilpie, Sheppy, Waldo, tschneidereit, Jorend
 Last updated by: arai,