JSFiddle - React, Tailwind, and code Playground

by amatiasq

HTML

<script src="http://amatiasq.com/fiddle-console.js"></script>

JavaScript

function createInstance(Type) {
    var instance = Object.create(Type);
    instance.constructor();
    return instance;
}

var Type = {
    constructor: function() {
        this.id = 1;
    }
};

var instance1 = createInstance(Type);
console.log(instance1.id);

var TypeWithoutConstructor = {};
var instance2 = createInstance(TypeWithoutConstructor);
console.log(instance2);