JSFiddle - React, Tailwind, and code Playground

by phloe

JavaScript

function C (name) {
  this.name = name;
};

function B (name) {
  this.name = name;
  this.scopeName = b();
      console.log("B", this.name, this);
  
  function b () {
    if (window.console) {
      console.log("b", this.name, this);
    }
    return this.name;
  }
}

Function.prototype.create = function () {
  var instance = new this;
  this.apply(instance, arguments);
  return instance;
}

var c = C.create("foo");

if (window.console) {
  console.log("c", c);
}

B("foo");