JSFiddle - React, Tailwind, and code Playground

by darcyclarke

JavaScript

//////////////////////////////////////////////////////////////
// WATCH OUT! Undefined variables will hoist up in scope...
//////////////////////////////////////////////////////////////

(function(){
    var privateVar = 'test';
})();
// console.log(privateVar); // 'error var not defined' Good!

(function(){
    var privateVar = PV = 'test';
})();
// console.log(privateVar); // 'error var not defined' Great!
// console.log(PV); // 'test' WTF?!

(function(){
    var PV;
    var privateVar = PV = 'test';
})();
// console.log(privateVar); // 'error var not defined' Yep...
// console.log(PV); // 'error var not defined' Much Better!