I’ve noticed significant changes in how JavaScript seems to store and manage variables, especially when debugging.
Previously, I could easily distinguish between variables declared with var
, let
, and const
in the browser’s debugger. var
variables were under the global window
object, while let
and const
were in the Script
object. I could also access these variables directly using window.variableName
.
However, this behavior seems to have changed. Now, I can’t find these variables under the window
object, and they all appear under a modules
object in the debugger. Additionally, var
variables show up as undefined
, while let
and const
have <Value unavailable>
.
I’m confused about how this affects variable scope, especially regarding the Temporal Dead Zone (TDZ).
- How does this new behavior work with the TDZ?
- Where are these variables actually stored now?
Any insights or explanations would be greatly appreciated.