Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

JS_GetClass

Retrieves the class associated with an object.

Syntax

const JSClass *
JS_GetClass(JSObject *obj);
Name Type Description
cx JSContext * Any context associated with the runtime in which obj exists.
obj JSObject * Object to get the class from.
In SpiderMonkey versions prior to SpiderMonkey 1.8.8, JS_GetClass took both a JSContext* and a JSObject* as arguments in thread-safe builds, and in non-thread-safe builds it took only a JSObject*.  The JS_GET_CLASS(cx, obj) macro abstracted away this detail.  Newer versions have removed the context argument, so that the same signature is used regardless whether or not the build is thread-safe.

Description

JS_GetClass returns a pointer to the JSClass associated with a specified JS object, obj. The application must treat the JSClass as read-only. If obj has no JSClass, this returns NULL.

To check the type of an object, use JS_HasInstance instead. For a stricter, exact-match-only check, use JS_InstanceOf or JS_GetInstancePrivate.

See Also

Document Tags and Contributors

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