O'Reilly logo
  • Ahmed Elgendy thinks this is interesting:

If the two values have different types, try to convert them into the same type and then compare them

This is the more interesting case. Say you have two values with different types that you want to compare, like a number and a string. What JavaScript does is convert the string into a number, and then compares the two values. Like this:


Cover of Head First JavaScript Programming


How does equality operator work?