JS_ValueToId

Converts a jsval to type jsid.

Syntax

JSBool JS_ValueToId(JSContext *cx, jsval v, jsid *idp);
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 jsval The JS value to convert.
idp jsid * Out parameter. On success, *idp receives the converted jsid.

Description

JS_ValueToId converts a specified jsval, 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.

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

The inverse is JS_IdToValue.

MXR ID Search for JS_ValueToId

Document Tags and Contributors

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