Available in Chrome 46+ | View on GitHub | Browse Samples


The value is part of the ES2015 (formerly known as ES6) specification, and can take one of two values: is useful for distinguishing at runtime whether code is being executed as a constructor or as a function. It is also handy as a way to determine the specific subclass that was used with new from within a superclass constructor.

Live Output

JavaScript Snippet

'use strict';
class Parent {
  constructor() {
    // is a constructor reference, and is human-friendly name.
    /* jshint ignore:start */
    ChromeSamples.log('Hello from Parent! ' +
      'I was constructed via new ' + + '()');
    /* jshint ignore:end */

class FirstChild extends Parent {}

class SecondChild extends Parent {}

function notAConstructor() {
  /* jshint ignore:start */
  ChromeSamples.log('Hello from notAConstructor()! My is ' +;
  /* jshint ignore:end */

// Call all the constructors and the function when the page loads.
new Parent();
new FirstChild();
new SecondChild();