What's wrong with defining JavaScript variables within if blocks? - Stack Overflow

Updated . Posted . Visible to the public.

Because javascript has something called "Hoisting" which makes your code do things it doesn't look like it should be doing. Basically, that means a javascript interpreter will move all var declarations, regardless of where they are in the body of a function, to the top of the function body.

Last edit
Keywords
javascript, omg
License
Source code in this card is licensed under the MIT License.
Posted by Lexy to makandra dev (2010-05-18 19:14)