Obsolete since JSAPI 8
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.
JSObject * JS_NewScriptObject(JSContext *cx, JSScript *script);
||The context in which to create the new script object. Requires request. In a
||The compiled script for which to create a new script object.|
JS_NewScriptObject returns the script object associated with the given
Every JSScript object has an associated JSObject script object. As long as the script object is reachable, the JSScript and its components are protected from garbage collection; when the script object is collected, the JSScript and its contents are freed. Once you have created a script, you should immediately ensure that its script object is reachable (perhaps by using
A script object has no properties, and its prototype is
Object.prototype. So a script object can be used to expose a
JS_NewScriptObject returns a pointer to the script's object. Otherwise it returns
(The name "
JS_NewScriptObject" suggests that the script object is freshly allocated; this was the case in older versions of the API, but now the script object is allocated along with the JSScript itself.)
(Some temporary scripts used internally by SpiderMonkey do not have script objects allocated for them; such scripts are not accessible via JSAPI.)