jsnice icon indicating copy to clipboard operation
jsnice copied to clipboard

Variable from a top-level closure gets overridden in a nested level function which creates a new variable with the same name

Open harpreetkhalsagtbit opened this issue 5 years ago • 0 comments

I have a following case(I can understand its a very rare case)


(function() {
    return (function(i) {
        function() {
            function() {
                if() {
                    if(!i){
                        // this is replacing the value of i
                        // from top closures
                        var i = 'somehing';
                        // this variable should not be i

                        //call i from top closures
                        i() // error not a function
                    }
                } else {

                }
            }
        }
    })
})()()

harpreetkhalsagtbit avatar Feb 17 '20 10:02 harpreetkhalsagtbit