There was a problem when chrome,js was debugging in debug. Is this chrome's bug?

clipboard.png
when the following line is commented out, the console print scope will report an error
, but when it is released, it will print out
I understand that the inside should hold a reference to the outer scope, whether there is the following line or not.
is this the optimization mechanism of chrome?

Mar.10,2021

although it may be a good habit to be skeptical, I still want to say that don't always doubt whether this is a bug, especially for a mature tool like chrome, even if you have bug, it is almost impossible for you to find it, especially in such a simple scenario.

this is a basic feature of closures. The inner scope does have access to variables in the outer scope, but only if a closure is formed (except for global variables). After you comment out, the scope is no longer in the closure and is of course inaccessible.

Menu