JavaScript > Greater than Operator
The greater than operator (>) checks whether the left value is larger than the right one.
Description
The greater than operator > returns true if the left operand is larger. Numbers compare numerically, but two strings compare character by character by their UTF-16 codes, so '10' > '9' is false and 'a' > 'B' is true. A string and a number are compared as numbers. Any comparison with NaN is false.
When one operand is a string and the other a number, the string is converted to a number, so '10' > 9 is true. Objects are converted to primitives first, which is why dates can be compared directly as timestamps. BigInts and numbers can be compared with each other, such as 10n > 5.
For sorting or comparing words alphabetically in a way that respects language rules, use localeCompare() or Intl.Collator rather than > on strings.
Properties
- Operator
>- Category
- Comparison
- Precedence
- 9 (1 is lowest, 18 is highest)
- Associativity
- left-to-right
Syntax
x > yExample
Browser Support
The following information will show you the current browser support for the > operator. Hover over a browser icon to see the version that first introduced support for this operator.
Desktop





Tablets & Mobile





