JSFiddle - React, Tailwind, and code Playground
JavaScript
function Something()
{
this.constructed;
if (Something.prototype.isPrototypeOf(this) && !this.constructed)
{
alert("called as a c'tor"); this.constructed = true;
}
else
{
alert("called as a function");
}
}
Something(); // "called as a function"
new Something(); // "called as a c'tor"
var x = new Something(); // "called as a c'tor"
x.func = Something;
x.func(); // "called as a function"