JavaScript·Intermediate·Conceptual·1 min read
Does var attach to globalThis?
Short interview answer
At the top level of a classic browser script, a global var declaration generally creates a property on the global object. Top-level let and const do not. ES modules have their own module scope and do not expose top-level declarations as global object properties.
Key takeaway
Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.