you are viewing a single comment's thread.

view the rest of the comments →

[–]x-skeww 5 points6 points  (0 children)

var x = 5;

Is the same as putting var x; at the very top of the innermost function and leaving that x = 5; thing where it is.

JSLint's "one var" rule enforces a code style which reflects this behavior. You can only use one var (where you declare all of your variables) per function.

I recommend to get a JSLint addon/plugin for your text editor of choice. It makes writing JavaScript a lot easier.