Hacker News new | ask | show | jobs
by timdown 5524 days ago
Generally not bad, but there are some errors and oversights in here:

- At the end of the "Always Use === Comparison" section, the example will throw a ReferenceError if (as is suggested) the variable `bar` has not been declared. If you're testing a variable that may not have been declared, you either need to use a `typeof` check or declare bar using `var bar;`, which will be essentially a no-op if bar exists and declares it with a value of `undefined` otherwise.

- The comments example is demonstrating unnecessary comments. The check and the call in

if (zeroAsAString === 0) { doHeapsOfStuff(param1, param2) }

... are self-explanatory to even the an inexperienced developer and do not require comment. What may require comment is why the code performs this check and this call.

- Your array in the "Loop Performance - Use ‘break;’ & ‘continue;’" section has one element. I know it's just an example, but it would be better as an example if it worked. You could instead use

var bigArray = new Array(1000);

- Chaining has downsides, the main one being it makes debugging much harder. You might want to mention this.