Created
July 16, 2014 17:30
-
-
Save TJkrusinski/941ec7ef19b29df8ec01 to your computer and use it in GitHub Desktop.
equality yum yums
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
var a = Object.create(null); | |
a.toString = function() { | |
return 4; | |
}; | |
a == 4; | |
// truthy! | |
typeof a == typeof 4; | |
// falsey |
Loose equality operator with operands of disparate types calls toString()
or valueOf()
depending on the types of the operands.
Much amaze.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Makes total sense actually.