Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Greater-than-or-equal operator (>=)

The >= operator checks whether the left operand is greater than or equal to the right operand. Comparison can convert types, so strings, null, and NaN deserve particular attention.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

left >= right

left >= right is a greater-than-or-equal comparison. If it completes without throwing, it returns true or false. Unlike >, it includes equality, so 18 >= 18 produces true. Use it to check a lower bound, such as a minimum age.

Objects are first converted to primitive values with a numeric hint; this can run user code or throw an exception. If both resulting values are strings, comparison is lexicographic by UTF-16 code units, not numeric: "10" >= "2" produces false. Otherwise, numeric conversion rules apply: "10" >= 2 produces true, and null >= 0 produces true.

Numeric comparison involving NaN, including one produced by converting undefined, produces false. Therefore, do not replace left >= right with !(left < right): their results differ for NaN. The operator is not shorthand for left > right || left == right, either. Comparing a Symbol value throws a TypeError.

You can compare a Number with a BigInt; for example, 2n >= 2 produces true. This does not mean they can freely be mixed in arithmetic. For input that must represent numbers, explicitly convert and validate the values before comparing them.

Examples

console.log(18 >= 18);
console.log(17 >= 18);
console.log("10" >= "2");
console.log("10" >= 2);
console.log(null >= 0);
console.log(NaN >= 0);

Result

true
false
false
true
true
false

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources