Jslint is a javascript verification tool (www.jslint.com) that can scan JavascriptSource codeTo find the problem. If jslint finds a problem, jslint will display a message describing the problem and point out the error in the sourceCode. Some encoding style conventions may cause unforeseen behaviors or errors. In addition to pointing out these unreasonable conventions, jslint can also mark structural problems. Although jslint cannot ensure that the logic is correct, it does help to identify errors, which may cause the JavaScript engine of the browser to throw errors.
Jslint defines a set of encoding conventions, which is stricter than the language defined by ECMA. These coding conventions draw on years of rich coding experience and take a long-standing programming principle as its purpose: Doing it does not mean doing it. Jslint adds a flag to the Code practices that it deems risky, and points out which are obvious errors (see Figure 5-12), so that you can develop good JavaScript coding habits.
Figure 5-12 jslint checks errors and bad encoding styles to provide JavaScript Verification
Jslint may mark some structural errors as suspicious encoding practices. Some of them are listed below (For a complete list, refer to the jslint documentation ).
L jslint requires that all code lines end with a semicolon. Although JavaScript does allow a line break as a line terminator, it is generally considered ambiguous and a bad encoding style.
L if and for statements must be enclosed in braces.
L different from otherProgramming LanguageIn JavaScript, blocks are not used as the scope of variables. Javascript only supports function-level scopes. Therefore, jslint only accepts blocks that are part of the function, if, switch, while, for, do, and try statements. Other blocks are marked as errors.
L var can only be declared once, and must be declared before use.
L jslint marks the code that appears after the return, break, continue, or throw statements as unfeasible code. These statements must be followed by an ending braces.
For JavascriptProgramFor beginners, jslint is a very good tool because it will teach you some good JavaScript coding practices. Because jslint can mark parts that may cause logical errors or other unforeseen behaviors, debugging time can be reduced. If you encounter difficulties in debugging A JavaScript code, try jslint.