Skip to content
JavaScript·Intermediate·Conceptual·1 min read

What is shadowing?

Short interview answer

An inner declaration can use the same name as an outer binding, causing resolution inside the inner scope to select the nearer binding. It is legal in many cases but can reduce clarity; some var/lexical combinations are early syntax errors.

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to Scope and hoisting

Related questions