- Made a comment a complete sentence, to match the style of the rest of
the document.
- Removed discussion of for/in over Arrays, since it's a can of worms,
and for/of is more appropriate if ES6 operators are available.
- Reworded introduction to prototypes, and moved it with the rest of the
prototype documentation.
- Prototypes are referenced in Section 3 before being discussed (in Section 5)
- Also, prototypes are referenced while talking about for-loops, which
IMHO distracts from the discussion of the loop structure itself
- Added example that shows prototype-chain-walking via for-in in Section 5
Previous incarnations of this section had `Number(0)` instead of
`new Number(0)`, which actually returns `0` due to the absence of the
`new` keyword; this commit re-adds that section and better still, makes
it actually correct!
Added a semicolon to conform with statement at top of guide:
// Because those cases can cause unexpected results, we'll keep on using
// semicolons in this guide.
Added some markdown formatting to the comments throughout to clarify meaning. Also tweaked a couple of other quote marks as well. Also shortened a couple of long lines.
More to do, but stopped here for now. :)
JavaScript is full of oddities .. I definitely wouldn't claim everything works "as it should" .. you don't have to include the gotcha's but I don't know, they're not that confusing for me.
Subject Line: Addresses Comparisons in Javascript
What Happened:
I believe that starting out with the double equals instead of the triple equals for strict comparison checking is incorrect. Because double equals uses type coercion, it is more of a feature the needs to be understood. Beginners looking at the language should look upon the stricter method as the proper one because it is less likely to give a surprising result.
I also tried to address the behaviour by adding an example to the double equals comparison.
Hope that the community is interested in pulling in these changes, they stem from teaching beginners javaScript but I am by no means the authority.