Permalink
Browse files

for

  • Loading branch information...
1 parent 5501c5c commit bd6da6b0eb808cf9c2813d8952591898d8f580b6 @douglascrockford committed Nov 25, 2013
Showing with 10 additions and 9 deletions.
  1. +10 −9 lint.html
View
@@ -277,12 +277,15 @@ <h1 id=forin><code>for</code> <code>in</code></h1>
wrapped in an <code>if</code> statement that does filtering. It can select
for a particular type or range of values, or it can exclude functions,
or it can exclude properties from the prototype. For example,</p>
-<blockquote><code>for (name in object) {
@alexo
alexo Jan 9, 2014

I would normally raise an issue for my request, but there is no issues section on JSLint github project page, so apologize for commenting here. It would be very helpful if JSLint would have periodic tagged releases. This would help clients using JSLint to refer to some particular version when reporting a problem or asking for a feature.

@douglascrockford
douglascrockford via email Jan 9, 2014 owner
@alexo
alexo Jan 9, 2014

Would it be possible to create tags (in git) for stable versions? It would help to easily switch between different jslint versions.

@douglascrockford
douglascrockford Jan 9, 2014 owner

I don't make unstable versions.

@bitmole
bitmole Jan 9, 2014

Would it be possible to tag each "edition"?

+<blockquote>
+ <code>for (name in object) {
if (object.hasOwnProperty(name)) {
- ....
+ ....
}
+
+ }</code></blockquote>
+ <p>In most cases, the <code>for</code> statement should be avoided completely. You should rely on methods like <code>Object.keys</code> and <code>Array.prototype.forEach</code> instead.</p>
-}</code></blockquote>
<h1 id=switch><code>switch</code></h1>
<p>A <a href="http://yuiblog.com/blog/2007/04/25/id-rather-switch-than-fight/">common
@@ -307,7 +310,7 @@ <h1 id=var><code>var</code></h1>
as a <code>var</code>.</p>
<p><code>JSLint</code> does not expect that a var will be defined in a block.
This is because JavaScript blocks do not have block scope. This can have
- unexpected consequences. Define all variables at the top of the function.</p>
+ unexpected consequences. Define all variables at the top of the function. It is easier to comply with this convention is if you use one <code>var</code> statement per function.</p>
<h1 id=with><code>with</code></h1>
@@ -335,7 +338,7 @@ <h1 id=assignment>=</h1>
<h1 id=eqeq>== and !=</h1>
<p>The <code>==</code> and <code>!=</code> operators do type coercion before
comparing. This is bad because it causes <code>' \t\r\n' == 0</code> to
- be <code>true</code>. This can mask type errors. <code>JSLint</code> cannot reliably determine if == is being used correctly, so it is best to not use <code>==</code> and != at all and to always use the more reliable <code>===</code> and <code>!==</code> operators instead. </p>
+ be <code>true</code>. This can mask type errors. <code>JSLint</code> cannot reliably determine if <code>==</code> is being used correctly, so it is best to not use <code>==</code> and <code>!=</code> at all and to always use the more reliable <code>===</code> and <code>!==</code> operators instead. </p>
<p align="left">If you only care that a value is <i>truthy</i> or <i>falsy</i>,
then use the short form. Instead of </p>
<blockquote><code>(foo != 0)</code></blockquote>
@@ -365,7 +368,7 @@ <h1 id=pluses>Confusing Pluses and Minuses</h1>
<p><code>JSLint</code> expects that <code>+</code> will not be followed by
<code>+</code> or <code>++</code>, and that <code>-</code> will not be followed
-by <code>-</code> or <code>--</code>. A misplaced space can turn <code>+ +</code> into <code>++</code>, an error that is difficult to see. Use parens to avoid confusion..</p>
+by <code>-</code> or <code>--</code>. A misplaced space can turn <code>+ +</code> into <code>++</code>, an error that is difficult to see. Use parens to avoid confusion.</p>
<h1 id=inc><code>++</code> and <code>--</code></h1>
<p>The <code>++</code> <small>(increment)</small> and <code>--</code> <small>(decrement)</small>
operators have been known to contribute to bad code by encouraging excessive
@@ -420,8 +423,6 @@ <h1 id=new>Constructors and <code>new</code></h1>
<code>new String</code>, <code>new Boolean</code>. </p>
<p><code>JSLint</code> does not expect to see <code>new Object</code>. Use <code>{}</code>
instead. </p>
-<p><code>JSLint</code> does not expect to see <code>new Array</code>. Use <code>[]</code>
- instead.</p>
<h1 id=properties>Properties</h1>
<p>Since JavaScript is a loosely-typed, dynamic-object language, it is not
possible to determine at compile time if property names are spelled correctly.
@@ -623,7 +624,7 @@ <h1 id=options>Options</h1>
<td>Tolerate stupidity<br>
</td>
<td><code>stupid</code></td>
- <td><code>true</code> if blocking (<code>'...Sync'</code>) methods can be used.</td>
+ <td><code>true</code> if blocking (<code>-Sync</code>) methods can be used.</td>
</tr>
<tr>
<td>Tolerate inefficient subscripting<br>

0 comments on commit bd6da6b

Please sign in to comment.