MDN wants to learn about developers like you:


This article covers features introduced in SpiderMonkey 17

Return the global object for the specified compartment.


JSObject *
JS_GetGlobalForCompartmentOrNull(JSContext *cx, JSCompartment *c);
Name Type Description
cx JSContext * The context for which to return the global object. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
c JSCompartment * The compartment for which to return the global object.


JS_GetGlobalForCompartmentOrNull() returns the global object for the context and the compartment. This may return NULL if c never had a global (e.g., the atoms compartment), or if c's global has been collected.

See also

Document Tags and Contributors

 Contributors to this page: kscarfone, arai
 Last updated by: kscarfone,