Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. JavaScript
  3. Reference
  4. Expressions and operators
  5. Greater than (>)

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.

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: true

Syntax

js
x > y

Description

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"; // true

String to number comparison

js
"5" > 3; // true"3" > 3; // false"3" > 5; // false"hello" > 5; // false5 > "hello"; // false"5" > 3n; // true"3" > 5n; // false

Number to Number comparison

js
5 > 3; // true3 > 3; // false3 > 5; // false

Number to BigInt comparison

js
5n > 3; // true3 > 5n; // false

Comparing 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; // false

Specifications

Specification
ECMAScript® 2026 Language Specification
# sec-relational-operators

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp