Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 840081 of new.target

  • Revision slug: Web/JavaScript/Reference/Operators/new.target
  • Revision title: new.target
  • Revision id: 840081
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment bug 1141865

Revision Content

{{JSSidebar("Operators")}}

The new.target syntax is available in all functions. In constructors, new.target refers to the constructor that was invoked by new. In normal function calls, new.target is {{jsxref("undefined")}}.

Syntax

new.target

Description

TBD

Examples

Using new.target in function calls

// TBD

Using new.target in classes

// TBD

Using new.target in arrow functions

// TBD

Specifications

Specification Status Comment
{{SpecName('ES6', '#sec-built-in-function-objects', 'Built-in Function Objects')}} {{Spec2('ES6')}} Initial definition.

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatNo}} {{CompatGeckoDesktop(41)}} {{CompatNo}} {{CompatNo}} {{CompatNo}}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatNo}} {{CompatNo}} {{CompatGeckoMobile(41)}} {{CompatNo}} {{CompatNo}} {{CompatNo}}

See also

Revision Source

<div>{{JSSidebar("Operators")}}</div>

<p>The<strong> <code>new.target</code></strong> syntax is available in all functions. In constructors, <code>new.target</code> refers to the constructor that was invoked by <code><a href="/en-US/docs/Web/JavaScript/Reference/Operators/new">new</a></code>. In normal function calls, <code>new.target</code> is {{jsxref("undefined")}}.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">
new.target</pre>

<h2 id="Description">Description</h2>

<p>TBD</p>

<h2 id="Examples">Examples</h2>

<h3 id="Object_type_and_object_instance">Using <code>new.target</code> in function calls</h3>

<pre class="brush: js">
// TBD
</pre>

<h3 id="Object_type_and_object_instance">Using <code>new.target</code> in classes</h3>

<pre class="brush: js">
// TBD
</pre>

<h3 id="Object_type_and_object_instance">Using <code>new.target</code> in arrow functions</h3>

<pre class="brush: js">
// TBD
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-built-in-function-objects', 'Built-in Function Objects')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatGeckoDesktop(41)}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Chrome for Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatGeckoMobile(41)}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{jsxref("Function")}}</li>
 <li><a href="/en-US/docs/Web/JavaScript/Reference/Classes">Classes</a></li>
 <li><code><a href="/en-US/docs/Web/JavaScript/Reference/Operators/new">new</a></code></li>
 <li><code><a href="/en-US/docs/Web/JavaScript/Reference/Operators/this">this</a></code></li>
</ul>
Revert to this revision