Understanding JavaScript Scope Like a Senior Engineer (Without Getting a Headache)

Scope is where you go looking when JavaScript wants a variable. The trick is knowing where it looks — and when.