JS Built-ins
TypeCoercionbeginner

Loose Equality (==)

Loose Equality (==)

The == operator coerces types before comparing values.

  • 1 == '1' is true (number compared to string, string is coerced to number)
  • 0 == false is true (both coerce to 0)
  • null == undefined is true (special case in loose equality)

Challenge: Return an object with three boolean properties showing the results of loose equality comparisons.

πŸ’‘ Hints (3)
  • β€’ Loose equality (==) coerces operands to the same type before comparing.
  • β€’ Different types can still be equal with ==: 1 == "1" is true.
  • β€’ null == undefined is a special case that returns true.