JS_ValueToId

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_ValueToId
  • Revision title: JS_ValueToId
  • Revision id: 146645
  • Created:
  • Creator: Jorend
  • Is current revision? No
  • Comment Requires request.

Revision Content

{{template.Jsapiref()}}

Converts a JS value to a JS ID.

Syntax

JSBool JS_ValueToId(JSContext *cx, jsval v, jsid *idp);
Name Type Description
cx JSContext * Pointer to a JS context from which to derive runtime information. {{wiki.template('Jsapi-requires-request')}}
v jsval The JS value to convert.
idp jsid * Pointer to the JS ID that contains the converted value when the function returns.

Description

JS_ValueToId converts a specified JS value, v, to a JS ID. If v already contains a JS_INT value, idp is set to point at v. Otherwise, JS_ValueToId attempts to generate an ID value based on the current value of v.

The converted value is stored in the jsid pointed to by idp. If the conversion is successful, JS_ValueToId returns JS_TRUE. Otherwise, it returns JS_FALSE.

See Also

Groups Functions
Documents {{template.LXRSearch("ident", "i", "JS_ValueToId", "LXR ID Search")}}
Entries

JS_ConvertArguments, JS_ConvertValue, JS_GetTypeName, JS_IdToValue, JS_TypeOfValue, JS_ValueToFunction, JS_ValueToInt32, JS_ValueToNumber, JS_ValueToObject, JS_ValueToString

Revision Source

<p> 
{{template.Jsapiref()}}
</p><p>Converts a JS value to a JS ID.
</p>
<h2 name="Syntax"> Syntax </h2>
<pre class="eval">JSBool JS_ValueToId(JSContext *cx, jsval v, jsid *idp);
</pre>
<table class="fullwidth-table">
<tbody><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td><code>cx</code></td>
<td><code>JSContext *</code></td>
<td>Pointer to a JS context from which to derive runtime information.
{{wiki.template('Jsapi-requires-request')}}</td>
</tr>
<tr>
<td><code>v</code></td>
<td><code>jsval</code></td>
<td>The JS value to convert.</td>
</tr>
<tr>
<td><code>idp</code></td>
<td><code>jsid *</code></td>
<td>Pointer to the JS ID that contains the converted value when the function returns.</td>
</tr>
</tbody></table>
<h2 name="Description"> Description </h2>
<p><code>JS_ValueToId</code> converts a specified JS value, <code>v</code>, to a JS ID. If <code>v</code> already contains a <code>JS_INT</code> value, <code>idp</code> is set to point at <code>v</code>. Otherwise, <code>JS_ValueToId</code> attempts to generate an ID value based on the current value of <code>v</code>.
</p><p>The converted value is stored in the <code>jsid</code> pointed to by <code>idp</code>. If the conversion is successful, <code>JS_ValueToId</code> returns <code>JS_TRUE</code>. Otherwise, it returns <code>JS_FALSE</code>.
</p>
<h2 name="See_Also"> See Also </h2>
<table class="fullwidth-table">
<tbody><tr>
<td>Groups</td>
<td><a href="en/JSAPI_Reference#Functions">Functions</a></td>
</tr>
<tr>
<td>Documents</td>
<td>{{template.LXRSearch("ident", "i", "JS_ValueToId", "LXR ID Search")}}</td>
</tr>
<tr>
<td>Entries</td>
<td>
<p><a href="en/JS_ConvertArguments">JS_ConvertArguments</a>,
<a href="en/JS_ConvertValue">JS_ConvertValue</a>,
<a href="en/JS_GetTypeName">JS_GetTypeName</a>,
<a href="en/JS_IdToValue">JS_IdToValue</a>,
<a href="en/JS_TypeOfValue">JS_TypeOfValue</a>,
<a href="en/JS_ValueToFunction">JS_ValueToFunction</a>,
<a href="en/JS_ValueToInt32">JS_ValueToInt32</a>,
<a href="en/JS_ValueToNumber">JS_ValueToNumber</a>,
<a href="en/JS_ValueToObject">JS_ValueToObject</a>,
<a href="en/JS_ValueToString">JS_ValueToString</a>
</p>
</td>
</tr>
</tbody></table>
Revert to this revision