04/28/06: JSLint

I've been doing a lot of JavaScript (and a lot of cursing) lately. Edward pointed me to JSLint, which checks the syntax and style of your JS code. I think it's too strict (but it's supposed to be) but I do recommend reading the documentation -- the explanations of /why/ JSLint complains are clear and insightful.

For instance:
The == and != operators do type coercion before comparing. This is bad because it causes '' == 0 to be true. This can mask type errors.

When comparing to any of the following values, use the === or !== operators, which do not do type coercion.

0 '' undefined null false true

If you want the type coercion, then use the short form. Instead of

(foo != 0)

just say


and instead of

(foo == 0)



See and

There's also a command-line version which could be used in a continuous build (though I'd recommend we're careful deciding which checks to activate). P.S. "JSLint is less anal than the sycophantic conformanity demanded by XHTML, but more strict than the popular browsers." That's my favorite sentence I've read all week.

Comments made

The procedure that would be mounted in order for one to secure an investment in any of these should not be really that easy.
02/27/12 17:36:51

Add comment

Sorry, but due to blog comment spam, I have to ask you to create an account before you post a comment. Please log in (using the form on the top right of the page) or click here to create an account: Create an account!