JSFiddle - React, Tailwind, and code Playground
JavaScript
function usefulTypeof(obj) {
return obj === null ? "null" : obj.constructor.toString().replace(/[^\w$\s]+/g, "").split(/\s+/)[1];
}
document.writeln("<pre>");
document.writeln(usefulTypeof(null));
document.writeln(usefulTypeof(42));
document.writeln(usefulTypeof(false));
document.writeln(usefulTypeof(""));
document.writeln(usefulTypeof([]));
document.writeln(usefulTypeof({}));
document.writeln(usefulTypeof(new Date()));
document.writeln(usefulTypeof(Math));
document.writeln(usefulTypeof(document.createElement("a")));
document.writeln(usefulTypeof(new Function()));
document.writeln(usefulTypeof(baz));
document.writeln("</pre>");