Why does it matter that in Javascript, scope is function-level, not block-level?

Posted by Jian Lin on Stack Overflow See other posts from Stack Overflow or by Jian Lin
Published on 2010-04-27T17:50:12Z Indexed on 2010/04/27 17:53 UTC
Read the original article Hit count: 257

Filed under:
|

In the question

http://stackoverflow.com/questions/1451009/javascript-infamous-loop-problem

the accepted answer from Christoph's says that

JavaScript's scopes are function-level, not block-level

What if Javascript's scopes are block-level, then would the Infamous Loop problem still occur? But will there be a different (or easier way) to fix it?

Is it as opposed to other languages, where using a { would start a new scope?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about scope