JSFiddle - React, Tailwind, and code Playground

by gdoron

JavaScript

function bar() {
        var x = "outer";
    
        function foo() {
            alert(x); // {undefined} Doesn't refer to the outerscope x
            // Due the the var hoising next:        
            x = 'inner';
            var x;
            alert(x); // inner
    
        }
        foo();
    }
    
    bar();