JSFiddle - React, Tailwind, and code Playground

by Kikketer

JavaScript

// I have no control over this code:
    (function (t) {
        var critter = function (options) {
            // Initialize with options
            return options;
        };
        
        // I have window that's called "t"
        t.pollution = critter({
            doSomething: function (options) {
                // Do some stuff with options
                alert(t.garbage);
            }
        });
    })(window);
    // End of my "no control" code...
        
    // Sometime later...
    (function () {
        // Per the spec, I should modify global variable 'garbage'
        window.garbage = 'wow this is garbage';
        window.pollution.doSomething({});
        
        // I would like to change the "t" in the closure of doSomething();
    })();