JS_IsConstructing

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_IsConstructing
  • Revision title: JS_IsConstructing
  • Revision id: 105126
  • Created:
  • Creator: Dria
  • Is current revision? No
  • Comment

Revision Content

{{template.Jsapiref()}}

Summary

Function

Indicates the current constructor status of a given context.

Syntax

JSBool JS_IsConstructing(JSContext *cx);
Name Type Description
cx JSContext * Pointer to a JS context from which to derive runtime information.

Description

JS_IsConstructing determines whether or not a function constructor is in action within a given context, cx. If it is, JS_IsConstructing returns JS_TRUE. Otherwise it returns JS_FALSE.

Notes

If your constructor function does not verify if it is invoked as a function/method directly instead of as a constructor using new, it is possible for the application to hit a fatal assertion and die. The constructor may want to throw an exception when called as a method, for instance, instead of proceeding as usual, or to behave in another manner.

See Also

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

Revision Source

<p> 
{{template.Jsapiref()}}
</p>
<h2 name="Summary"> Summary </h2>
<p><b>Function</b>
</p><p>Indicates the current constructor status of a given context.
</p>
<h2 name="Syntax"> Syntax </h2>
<pre>JSBool JS_IsConstructing(JSContext *cx);
</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.</td>
</tr>
</tbody></table>
<h2 name="Description"> Description </h2>
<p><code>JS_IsConstructing</code> determines whether or not a function constructor is in action within a given context, <code>cx</code>. If it is, <code>JS_IsConstructing</code> returns <code>JS_TRUE</code>. Otherwise it returns <code>JS_FALSE</code>.
</p>
<h3 name="Notes"> Notes </h3>
<p>If your constructor function does not verify if it is invoked as a function/method directly instead of as a constructor using <code>new</code>, it is possible for the application to hit a fatal assertion and die. The constructor may want to throw an exception when called as a method, for instance, instead of proceeding as usual, or to behave in another manner.
</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_IsConstructing", "LXR ID Search")}}</td>
</tr>
</tbody></table>
Revert to this revision