Movatterモバイル変換


[0]ホーム

URL:


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

Greater than or equal (>=)

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 or equal (>=) operator returnstrue ifthe left operand is greater than or equal to the right operand, andfalseotherwise.

Try it

console.log(5 >= 3);// Expected output: trueconsole.log(3 >= 3);// Expected output: true// 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, with the result negated.x >= y is generally equivalent to!(x < y), except for two cases wherex >= y andx < y are bothfalse:

  • If one of the operands gets converted to a BigInt, while the other gets converted to a string that cannot be converted to a BigInt value (it throws asyntax error when passed toBigInt()).
  • If one of the operands gets converted toNaN. (For example, strings that cannot be converted to numbers, orundefined.)

x >= y is generally equivalent tox > y || x == y, except for a few cases:

  • When one ofx ory isnull, and the other is something that's notnull and becomes 0 whencoerced to numeric (including0,0n,false,"","0",new Date(0), etc.):x >= y istrue, whilex > y || x == y isfalse.
  • When one ofx ory isundefined, and the other is one ofnull orundefined:x >= y isfalse, whilex == y istrue.
  • Whenx andy are the same object that becomesNaN after the first step ofLess than (such asnew Date(NaN)):x >= y isfalse, whilex == y istrue.
  • Whenx andy are different objects that become the same value after the first step ofLess than:x >= y istrue, whilex > y || x == y isfalse.

Examples

String to string comparison

js
"a" >= "b"; // false"a" >= "a"; // true"a" >= "3"; // true

String to number comparison

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

Number to Number comparison

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

Number to BigInt comparison

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

Comparing Boolean, null, undefined, NaN

js
true >= false; // truetrue >= true; // truefalse >= true; // falsetrue >= 0; // truetrue >= 1; // truenull >= 0; // true1 >= 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