JavaScript: syntax checker

In this short post I'm going to share some really useful JavaScript syntax checker.

When programming we surely need to check what it's been done. It's better to verify the code when still in production, during the so-called test period. When published, a web site could still contain errors, but what we surely need to avoid is those annoying syntax errors.

There are specific programs freely available that we can use to do so. Here we are going to see 3 tools that we should carefully consider.



JSLint
"JSLint is a JavaScript program that looks for problems in JavaScript programs. It is a code quality tool. [...] JSLint takes a JavaScript source and scans it. If it finds a problem, it returns a message describing the problem and an approximate location within the source. The problem is not necessarily a syntax error, although it often is. JSLint looks at some style conventions as well as structural problems. It does not prove that your program is correct. It just provides another set of eyes to help spot problems. [...] JSLint can operate on JavaScript source, HTML source, CSS source, or JSON text."

As you can see it's quite a complete tool. It's obvious that there's no program that will say if a snippet is correct or not. What those tools can do is help us in spotting a possible issue. And maybe keep our code clean.

Just visit  JSLint web page and read for yourself what it can do for us.

JSHint
JSHint is in some way a more simple tool. First of all is an on-line tool and it ".. is a tool to detect errors and potential problems in JavaScript code and can be used to enforce coding conventions."

We just need to put the code, select what kind of checks we need and wait for results.

Again, visit the above web site for more information.

Jsdoc
The last tool is a bit different...
"JsDoc Toolkit is an application, written in JavaScript, for automatically generating template-formatted, multi-page HTML (or XML, JSON, or any other text-based) documentation from commented JavaScript source code."

The web site explains everything about it and it's worth visiting it, as we all know how important code documentation is (especially in large project).

Ok, folks... that's all for today.
If you use different JavaScript tools and you want to share them with us, please add them using the comments section below.