JS_GetGlobalForObject

by 3 contributors:

Returns the global object for the given object.

Syntax

JSObject *
JS_GetGlobalForObject(JSContext *cx, JSObject *obj);
Name Type Description
cx JSContext * A context. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
obj JSObject * A non-NULL JSObject.

Description

JS_GetGlobalForObject returns the last non-null object on the parent chain of the input object.

For function object inputs, the result is "the global object" as referred to in the ECMAScript specification. For example, if the function refers to a global variable foo, then foo is a property of the object returned by JS_GetGlobalForObject.

See Also

Document Tags and Contributors

Contributors to this page: arai, Sheppy, Dmandelin
Last updated by: arai,
Hide Sidebar