JS Built-ins
Operatorsbeginner

Operators β€” strict (===) vs loose (==) equality

Strict vs loose equality

=== checks value AND type β€” no coercion. == coerces types before comparing.

Challenge: Write compareEquality() returning an object with:

  • strictNumStr: 1 === '1'
  • looseNumStr: 1 == '1'
  • strictNullUndef: null === undefined
  • looseNullUndef: null == undefined
πŸ’‘ Hints (1)
  • β€’ null and undefined are only == to each other (and themselves), not to 0 or false