Answer the question
In order to leave comments, you need to log in
How to correctly scope a variable using ES6 and Babel?
Ok, we have code (function(){ /* code */ })();
that says that the variables will not go beyond the scope of this function. But! ES6 has let and const, which means that a variable declared in {const}
is also not leaky. But what if you use Babel? I don’t know how anyone, but I get the code at the output {var}
, and it definitely flows beyond the curly braces. Share your cases please)
______________Update__________________
It seems to me that Babel will work in such a way that the variable will still become var and leak out of the limit {}
, however, the transpiler (transpiler?) will change the name of the variable itself so that they do not intersect. See screenshot: prntscr.com/i683e4
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question