Created
November 3, 2011 03:15
-
-
Save bcherry/1335683 to your computer and use it in GitHub Desktop.
explanation of https://twitter.com/#!/angusTweets/status/130767521417662464
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Also not that `a + "a"` is "3a" (and "a3" the other way around) | |
I'm pretty certain it's because `typeof a === "object"` and `typeof "a" === "string"`. | |
The `+` operator calls `toPrimitive` on each operand, but since the literal strings | |
are already primitives, no further action is taken. It's only when they are | |
objects that it delegates to `[[DefaultValue]]` which ends up calling its `valueOf` method. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment