Unlike most programming languages, JavaScript does not have block-level scope (variables scoped to surrounding curly brackets); instead, JavaScript has function-level scope. Variables declared within a function are local variables and are only accessible within that function or by functions inside that function. 摘自 http://javascriptissexy.com/javascript-variable-scope-and-hoisting-explained/