background preloader

Code Quality

Facebook Twitter

Scott Logic » JSLint vs JSHint. In January of this year Douglas Crockford decided that some of the options in JSLint were generally accepted and should always be on. One of those options was eqeqeq, the option to show an error if just two equals was used. For some time JSLint has complained about double equal comparisons against null, 0, undefined and empty string, but this change meant that two variables had to be compared without type coercion. His point of view is that having a global style enforced through JSLint is a good thing and that the best way to do this would be to force anyone wanting to use JSLint to conform strictly to rules of his own devising.

In his own words, here is a quote from the readme. This applies to programming as well. Conforming to a consistent styleimproves readability, and frees you to express yourself in ways that matter.JSLint here plays the part of a stern but benevolent editor, helping you toget the style right so that you can focus your creative energy where it ismost needed. " JSLint. JSHint, A JavaScript Code Quality Tool.

Automatic semi-colon insertion. A semi-colon explicitly placed in the source text must terminate certain statements. Your JavaScript interpreter may help by adding some automatically, but this may not work as you expect. As they say, "Your mileage may vary". Semi-colons are used to explicitly terminate certain keywords so that the parser can determine exactly where the fragment of code begins and ends.

The semi-colon removes the ambiguity about how a piece of code is intended to execute. Line terminators greatly affect the automatic semi-colon insertion process. The following statements must have trailing semi-colons: empty statementvariable statementexpression statementcontinue statementbreak statementreturn statementthrow statement There are cases where the the interpreter will automatically insert semi-colons as needed.