N
N
nektobit2018-01-27 04:17:52
JavaScript
nektobit, 2018-01-27 04:17:52

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

1 answer(s)
R
RidgeA, 2018-01-27
@RidgeA

try it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question