If the js closure feature suddenly fails

var a = "global";
function b(){
    var a = "local";
    return function c() {
        console.log(a);
    }
}
b()()// "local"

the above is an example of closures. If js loses the closure features
, how can the function be modified to simulate the closure characteristics of js, so that the output results are consistent with those before the loss of features?

Mar.09,2021

closure function is to save the current scope
make use of the object
you can create an object inside the function and then return the current object to simulate the closure characteristics
it feels too tedious to know any other good suggestions

.
Menu