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


This article needs a technical review. How you can help.

Convert a JS::Value to type jsid.


JS_ValueToId(JSContext *cx, JS::HandleValue v, JS::MutableHandleId idp);

JS_StringToId(JSContext *cx, JS::HandleString s, JS::MutableHandleId idp); // Added in SpiderMonkey 38

JS_IndexToId(JSContext *cx, uint32_t index, JS::MutableHandleId idp); // Added in SpiderMonkey 17

JS_CharsToId(JSContext* cx, JS::TwoByteChars chars, JS::MutableHandleId idp); // Added in SpiderMonkey 24

JS::ProtoKeyToId(JSContext *cx, JSProtoKey key, JS::MutableHandleId idp); // Added in SpiderMonkey 38
Name Type Description
cx JSContext * A context. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
v JS::HandleValue The JS value to convert.
s JS::HandleString The JS string to convert.
index uint32_t An unsigned integer index of array to convert.
chars JS::TwoByteChars The string to convert.
key JSProtoKey The prototype key to convert.
idp JS::MutableHandleId Out parameter. On success, *idp receives the converted jsid.


JS_ValueToId converts a specified JS::Value, v, to a jsid. If v is an integer, *idp receives an integer jsid. Otherwise, if E4X support is enabled and v is an object, *idp receives an object jsid. Otherwise, *idp receives an interned string jsid based on the value of v. If v is not a string, it is converted to a string as if by calling JS_ValueToString.

JS_StringToId and JS_CharsToId convert a specified string to a jsid.

JS_IndexToId converts a specified integer index to an integer jsid.

JS::ProtoKeyToId converts a specified prototype key to a jsid.

On success, JS_ValueToId stores the converted value in *idp and returns true. Otherwise it returns false.

The inverse of JS_ValueToId is JS_IdToValue.

MXR ID Search for JS_ValueToId

See Also

Document Tags and Contributors

 Contributors to this page: kscarfone, arai, fscholz, Jorend, Dria, MMondor
 Last updated by: kscarfone,