JS_TypeOfValue

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_TypeOfValue
  • Revision title: JS_TypeOfValue
  • Revision id: 146672
  • Created:
  • Creator: Jorend
  • Is current revision? Yes
  • Comment 14 words removed

Revision Content

Determines the JS data type of a JS value.

Syntax

JSType JS_TypeOfValue(JSContext *cx, jsval v);
Name Type Description
cx JSContext * The context in which to perform the type check. {{ Jsapi-requires-request() }}
v jsval The value to examine.

Description

JS_TypeOfValue examines a specified JS value, v, and returns its JS data type. The return value is always one of JSTYPE_VOID, JSTYPE_OBJECT, JSTYPE_FUNCTION, JSTYPE_STRING, JSTYPE_NUMBER, or JSTYPE_BOOLEAN.

See Also

{{ LXRSearch("ident", "i", "JS_TypeOfValue") }}

JS_ConvertValue, JS_GetTypeName, JS_ValueToBoolean, JS_ValueToFunction, JS_ValueToInt32, JS_ValueToNumber, JS_ValueToObject, JS_ValueToString

Revision Source

<p>Determines the JS data type of a JS value.
</p>
<h2 id="Syntax" name="Syntax"> Syntax </h2>
<pre class="eval"><a href="/en/SpiderMonkey/JSAPI_Reference/JSType" title="en/JSType">JSType</a> <strong>JS_TypeOfValue</strong>(<a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSContext</a> *cx, <a href="/En/SpiderMonkey/JSAPI_Reference/Jsval" title="en/jsval">jsval</a> v);
</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><a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSContext</a> *</code></td>
<td>The context in which to perform the type check.
{{ Jsapi-requires-request() }}</td>
</tr>
<tr>
<td><code>v</code></td>
<td><code><a href="/En/SpiderMonkey/JSAPI_Reference/Jsval" title="en/jsval">jsval</a></code></td>
<td>The value to examine.</td>
</tr>
</tbody></table>
<h2 id="Description" name="Description"> Description </h2>
<p><code>JS_TypeOfValue</code> examines a specified JS value, <code>v</code>, and returns its JS data type. The return value is always one of <code>JSTYPE_VOID</code>, <code>JSTYPE_OBJECT</code>, <code>JSTYPE_FUNCTION</code>, <code>JSTYPE_STRING</code>, <code>JSTYPE_NUMBER</code>, or <code>JSTYPE_BOOLEAN</code>.
</p>
<h2 id="See_Also" name="See_Also"> See Also </h2>
<p>{{ LXRSearch("ident", "i", "JS_TypeOfValue") }}
</p><p><a href="/en/SpiderMonkey/JSAPI_Reference/JS_ConvertValue" title="en/JS_ConvertValue">JS_ConvertValue</a>,
<a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetTypeName" title="en/JS_GetTypeName">JS_GetTypeName</a>,
<a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToBoolean" title="en/JS_ValueToBoolean">JS_ValueToBoolean</a>,
<a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToFunction" title="en/JS_ValueToFunction">JS_ValueToFunction</a>,
<a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToInt32" title="en/JS_ValueToInt32">JS_ValueToInt32</a>,
<a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToNumber" title="en/JS_ValueToNumber">JS_ValueToNumber</a>,
<a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToObject" title="en/JS_ValueToObject">JS_ValueToObject</a>,
<a href="/en/SpiderMonkey/JSAPI_Reference/JS_ValueToString" title="en/JS_ValueToString">JS_ValueToString</a>
</p>
Revert to this revision