Main Page

JavaScript Verifier

As you can see, this reduces the amount of code contained in the
function and also makes it
clearer what the developer was thinking when writing this function.
The JavaScript Verifier
Douglas Crockford, a software engineer, wrote a small tool called jslint — The JavaScript Verifier. The
purpose of jslint is to point out unprofessional JavaScript syntax and possible syntax errors. You simply
paste your JavaScript code (either pure JavaScript code or code enclosed in a
tag) into a text
box and click the jslint button. The tool then outputs warnings and errors about your code underneath.
The types of warnings provided by jslint are in line with the professional standards mentioned through-
out this book. You receive a warning if the code contains an inappropriate coding technique, such as the
A statement (
, and so on) that doesn’t use block notation (see Chapter 2,
“ECMAScript Basics”)
A line that doesn’t end with a semicolon
statement declaring a variable name that is already in use
statement (for reasons to avoid
, see Chapter 2)
The JavaScript Verifier is available online at
and it can also be downloaded in its original source code for your own use.
Programmers used to developing in languages such as C, C++, Java, and Perl know that debugging is
an important part of the development process. These developers rely heavily on debuggers for such pro-
gramming languages to aid in tracking down errors in their code. Most languages offer some type of
debugger, from simple command line programs to exhaustive GUI layouts. Although JavaScript itself
doesn’t have a debugger, both Internet Explorer and Mozilla have debuggers available.
Microsoft Script Debugger
The Microsoft Script Debugger is a free utility available from Microsoft’s Web site. To download it, go to
and type
script debugger
into the Search box. The results list comes up with Script Debugger for Windows NT, 2000, XP. Click that
link and click the Download button. Run the installation program and then restart Internet Explorer.
Notice a new menu item that appears under the View menu called Script Debugger. This provides
options for running the debugger.
You can run the Microsoft Script Debugger in a number of ways. First, you can open it directly by select-
ing View
Script Debugger
Open, which opens the debugger with no information loaded. The second
method is to select View
Script Debugger
Break at Next Statement, which opens the debugger before
Chapter 14
17_579088 ch14.qxd 3/28/05 11:41 AM Page 432

JavaScript EditorFree JavaScript Editor     Ajax Editor