The new set of options. This is the logical OR of zero or more flags described below.
JS_SetOptions sets the option flags of a given JS context cx. This function returns a uint32 value containing the previous values of the flags.
To turn individual options on or off, use JS_SetOptions with JS_GetOptions:
// turn on warnings for dubious practices
JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_EXTRA_WARNINGS);
// turn off those extra warnings
JS_SetOptions(cx, JS_GetOptions(cx) & ~JSOPTION_EXTRA_WARNINGS);
The options parameter and the return value are the logical OR of zero or more constants from the following table:
Make JS_EvaluateScript() use the last object on its obj param's scope chain (that is, the global object) as the ECMA "variables object".
This flag is recommended. Without it, the two scripts "x = 1" and "var x = 1", where no variable x is in scope, do two different things. The former creates a property on the global object. The latter creates a property on obj. With this flag, both create a global property.
Caller of JS_CompileScript et al promises to execute the compiled script once only, in the same scope object used for compilation. The caller may not modify objects on the scope chain between compilation and execution. This enables compile-time scope chain resolution of consts (a performance optimization).
Added in SpiderMonkey 15 ECMAScript for XML (E4X) support: parse <!-- --> as a token, not backward compatible with the comment-hiding hack used in HTML script tags. Only used if JSOPTION_ALLOW_XML is set.
Thanks! Please check your inbox to confirm your subscription.
If you haven’t previously confirmed a subscription to a Mozilla-related newsletter you may have to do so. Please check your inbox or your spam filter for an email from us.
Why does MDN look different?
MDN is changing to focus just on documenting web technologies. All the same great content is still here; we’re just changing some visual elements and navigation, to help you more quickly find the web technology docs you’re looking for.
But don’t worry, MDN and Mozilla are still together! In fact, we're updating MDN’s look to reflect Mozilla's new logo and colors.