JSFiddle - React, Tailwind, and code Playground

JavaScript

// globally defined
    var glob = 'hi';
    (function() {
      var j = 4;
      console.log(j); // => 4
      console.log(glob); // => 'hi'
      console.log(inLoop); // => undefined
      
      // NB if this was set to anything not used in the scope then execution would be halted by an 'undefined' error in the code
      console.log(i); // => undefined
      for (var i = 0; i < 10; i ++) 
      { 
        var inLoop = 'xyz';
      }
      
      console.log(i); // => 10
      console.log(inLoop); // => 10
    }());
    console.log(glob); // => 'hi'