Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Javascripts Abstract Equality Algorithm in tabular form

Abstract Equality Comparison

Consider this expression:

x == y

Then,

Type(x) Type(y) Operation
same same Strict Equality Comparison: x === y
null undefined true
undefined null true
number string x == ToNumber(y)
string number ToNumber(x) == y
boolean any ToNumber(x) == y
any boolean x == ToNumber(y)
String, Number, Symbol object x == ToPrimitive(y)
object String, Number, Symbol ToPrimitive(x) == y
If all else fails, return false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.