Convert a JS::Value to type jsid.

Syntax

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

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

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

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

void
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.

Description

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