JSFiddle - React, Tailwind, and code Playground

by morrison

JavaScript

$a = function() {};

$ = function() {
    if (!(this instanceof $)) {
        return new $();
    }

    this.name = "levi";

    return this;
};

//helper function
var log = function(message) {
    document.write((message ? message : '') + "<br/>");
};

log("$().name == window.name: " + ($().name == window.name));
log("$().name: " + $().name);
log("window.name: " + window.name);

log();

log("$a instanceof $: " + ($a instanceof $));
log("typeof $a: " + (typeof $a));
log("typeof $: " + (typeof $));