JS Built-ins
TypeCoercionbeginner

Abstract Relational Comparison

Relational operators (<, >, <=, >=) behave differently depending on operand types. When at least one operand is a number, both are coerced to numbers. When both operands are strings, comparison is lexicographic (character by character) β€” no number coercion occurs. This is why '10' > '9' is false (lexicographic: '1' < '9') but '10' > 9 is true (numeric: 10 > 9).

πŸ’‘ Hints (3)
  • β€’ When both operands are strings, comparison is lexicographic (character by character).
  • β€’ When at least one operand is a number, both are coerced to numbers.
  • β€’ "10" as a string starts with "1" which is less than "9" lexicographically.