JSFiddle - React, Tailwind, and code Playground
HTML
<pre id="log">
</pre>
JavaScript
// j is never defined in the global namespace
// even though the code-block that defines j
// is never reached
;(function() {
log("before (global)", window.j) // undefined
log("before (local)", j) // undefed
// don't define j, but it gets defined anyway
// because of function scope and var-hoisting
if (false) {
var j = "hi";
} else {
j = "what";
}
log("after (local)", j) // what
log("after (global)", window.j) // undefined
}());
function log(a, b) {
$("#log").append(a + ": "+ b + "\n")
}