Syntax Errors in Javascript: JSLint saves the day
http://jslint.com
At runtime, firebug and Javascript Debugger will catch Javascript errors you need to worry about. But what it you’ve made a syntax error, and that Firebug completely ignores your js file… If you want to avoid hitting Ctrl-z until you find where you made the mistake, or worse, re-read line-by-line your 2000-lines-of-code script, here’s the solution: http://jslint.com
In addition to errors, it will indicate implied globals (just to make sure you didn’t forget that “var i = 0;”, and that your variable i keeps changing values event inside a loop iteration
because it calls another function that has also declared i as a global…
Last but not least, if you’re working on copyrighted code and you don’t feel safe about sending it to a remote server: As of today (Nov 11th 2008) all the processing is done in your browser (you can check with firebug: no network traffic after the page has loaded).
Wouldn’t it be a cool feature if firebug and other debuggers would just incorporate the JSlint code, in order to signal those kind of static errors.
Another issue is that Firebug requires you to put console objects in your code, so you can’t automatically test it in other browsers.
We have been looking at Visual Studio 2008, which uses JSLint. What do you think about it?