JSFiddle - React, Tailwind, and code Playground

JavaScript

function Foo() {
    if (!(this instanceof Foo)) 
        throw new TypeError("DOM object constructor cannot be called as a function.");

    this.identity = 'Bar';
}

try {
    console.log('Without "new":');
    var x = Foo();
} catch (e) {
    console.log(e);
}

try {
    console.log('With "new":');
    var y = new Foo();
} catch (e) {
    console.log(e);
}