JSFiddle - React, Tailwind, and code Playground

by andypotanin

JavaScript

function Template() {
  console.log( 'Primary Instance' )
  this.constructor.__proto__ = Template.prototype;
  return this.constructor;
};

Object.defineProperties( Template.prototype, {
    "constructor": {
        'value': function Template() {
            console.log( 'new Tempalte Constructor' )        
            return this.constructor;
        },
        'enumerable': true        
    },
    "a_method": {
        value: function () {},
        enumerable: true
    },
    "a_string": {
        'value': "Hello",
        'enumerable': true,
        'writable': true
    },
     "private": {
        'value': {
            'some': 'data'
        },
        'enumerable': false
    }
});

console.clear();

var test1 = new Template();
var test2 = new test1();
var test3 = new test2();

console.log( 'Template', typeof Template );
console.log( 'Template.constructor', typeof Template.constructor );
console.log( 'Test1', typeof test1 );
console.log( 'Test2', typeof test3 );
console.log( 'Test3', typeof test3 );

console.log( 'test1.a_string', test1.a_string );
console.log( 'test2.a_string', test2.a_string );