concept var keyword in category javascript
appears as: var keyword, The var keyword

This is an excerpt from Manning's book Secrets of the JavaScript Ninja, Second Edition.
When we use the var keyword, the variable is defined in the closest function or global lexical environment. (Note that blocks are ignored!) This is a long-standing detail of JavaScript that has tripped up many developers coming from other languages.