JSFiddle - React, Tailwind, and code Playground

by eithe

JavaScript

(function () {
    var scope = this;
    console.log(scope === window);
    
    scope.A = function() {
        alert('A');
    };
    
    scope.B = function() {
        alert('B');        
    };
    
    (function () {
        var fnc = 'A';
        //fnc();
        scope[fnc]();
    }());
}());

console.log(window.scope);