JSFiddle - React, Tailwind, and code Playground

by btipling

JavaScript

function Foo() {
}

var prototypeDef = {
    protoArray: [],
};
var propertiesDef = {
    propertyArrayValue_: {
        value: null,
        writable: true
    },
    propertyArray: {
        get: function () {
            if (!this.propertyArrayValue_) {
                this.propertyArrayValue_ = [];
            }
            return this.propertyArrayValue_;
        }
    }
}
 
var foo1 = new Foo();

console.log(foo1 instanceof Foo); //logs true
console.log(Foo.prototype.isPrototypeOf(foo1)); //true


var foo2 = Object.create(prototypeDef, propertiesDef);

console.log(prototypeDef.isPrototypeOf(foo2)); //true