JSFiddle - React, Tailwind, and code Playground

by AndreaLigios

HTML

<input type="button" value="press me" id="foo" onclick="alert();" />

JavaScript

var yourGlobalVariable; // Global to your code, invisible outside the scoping function

function auz (){ // Begin scoping function
    yourGlobalVariable="bar"; // Global to your code, invisible outside the scoping function
    var localz = "zzz";
    
    function foo() {
        yourGlobalVariable = "baz";
        alert (yourGlobalVariable);
        return localz;
    }
    
    return localz;// foo();
};         // End scoping function

var foobar = auz();

alert(foobar);