Skip to content

Instantly share code, notes, and snippets.

@TJkrusinski
Created July 16, 2014 17:30
Show Gist options
  • Save TJkrusinski/941ec7ef19b29df8ec01 to your computer and use it in GitHub Desktop.
Save TJkrusinski/941ec7ef19b29df8ec01 to your computer and use it in GitHub Desktop.
equality yum yums
var a = Object.create(null);
a.toString = function() {
return 4;
};
a == 4;
// truthy!
typeof a == typeof 4;
// falsey
@whichsteveyp
Copy link

Makes total sense actually.

@TJkrusinski
Copy link
Author

Loose equality operator with operands of disparate types calls toString() or valueOf() depending on the types of the operands.

@TJkrusinski
Copy link
Author

Much amaze.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment