Skip to content

Instantly share code, notes, and snippets.

@lap00zza
Last active November 11, 2017 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lap00zza/877046b574ac9a0be21eb5109c7f696d to your computer and use it in GitHub Desktop.
Save lap00zza/877046b574ac9a0be21eb5109c7f696d to your computer and use it in GitHub Desktop.
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