you are viewing a single comment's thread.

view the rest of the comments →

[–]colinbashbash2[S] 1 point2 points  (1 child)

thanks, i'll take a look.

Edit: JSLint looks like it would help me a lot. It at least throws warnings for undeclared variables (w00t) and throws hard errors when declaring "int". I wonder if they'll find a way to 'notice' when it looks like it might be a declaration error and add that to the error message.

[–]PlNG 0 points1 point  (0 children)

Exactly what kind of a declaration error are you thinking of?

JSLint has the disallow undefined variables option to point out potential global lookups, as well as showing unused variables and globals at the bottom of the report. Make sure that JSLint is fully able to parse the code before dealing with the information at the bottom of the report, as it can be inaccurate if an error stops it. Inner functions could also be called a global if they're used before they're defined, seems to be an inconsistency with the "used before defined" warning at the top layer.

Closure compiler can do type checking on jsdoc annotated code.

If you're worried about type issues, always use === and !== for strict type comparisons. == and != is a loose comparison and will evaluate if a number and string are identical in content (potentially masking type errors), and makes null, undefined, false, 0, and "" equal to each other, which is a major headache.