Greater than (>)
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Thegreater than (>) operator returnstrue if the leftoperand is greater than the right operand, andfalse otherwise.
In this article
Try it
console.log(5 > 3);// Expected output: trueconsole.log(3 > 3);// Expected output: false// Compare bigint to numberconsole.log(3n > 5);// Expected output: falseconsole.log("ab" > "aa");// Expected output: trueSyntax
js
x > yDescription
The operands are compared using the same algorithm as theLess than operator, except the two operands are swapped.x > y is generally equivalent toy < x, except thatx > y coercesx to a primitive beforey, whiley < x coercesy to a primitive beforex. Because coercion may have side effects, the order of the operands may matter.
Examples
>String to string comparison
js
"a" > "b"; // false"a" > "a"; // false"a" > "3"; // trueString to number comparison
js
"5" > 3; // true"3" > 3; // false"3" > 5; // false"hello" > 5; // false5 > "hello"; // false"5" > 3n; // true"3" > 5n; // falseNumber to Number comparison
js
5 > 3; // true3 > 3; // false3 > 5; // falseNumber to BigInt comparison
js
5n > 3; // true3 > 5n; // falseComparing Boolean, null, undefined, NaN
js
true > false; // truefalse > true; // falsetrue > 0; // truetrue > 1; // falsenull > 0; // false1 > null; // trueundefined > 3; // false3 > undefined; // false3 > NaN; // falseNaN > 3; // falseSpecifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-relational-operators> |