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

JS_GetContextPrivate

Access a JSContext field for application-specific data.

Syntax

void *
JS_GetContextPrivate(JSContext *cx);

void
JS_SetContextPrivate(JSContext *cx, void *data);

void *
JS_GetSecondContextPrivate(JSContext *cx); // Added in SpiderMonkey 17

void
JS_SetSecondContextPrivate(JSContext *cx, void *data); // Added in SpiderMonkey 17
Name Type Description
cx JSContext * Any context.
data void * (in JS_SetContextPrivate or JS_SetSecondContextPrivate) Pointer to application-defined data to be associated with the context cx.

Description

Each JSContext has two fields of type void * which the application may use for any purpose. They are especially useful for storing data needed by callbacks. JS_GetContextPrivate and JS_GetSecondContextPrivate get this field and JS_SetContextPrivate and JS_SetSecondContextPrivate set it. The field is initially NULL.

Memory management for this private data is the application's responsibility. The JavaScript engine itself never uses it.

See Also

Document Tags and Contributors

 Contributors to this page: arai, fscholz, Jorend, Cheatah, Dria, Nickolay, Tservo
 Last updated by: arai,