Greater Than or Equal To (>=) Comparison Operator

Summary

Returns true if the left operand is greater than or equal to the right operand.

Syntax

expression1 >= expression2

Parameters

expression1
Any legal expression.
expression2
Any legal expression.

Description

The "greater than or equal to" operator compares the values of two expressions. If the expression on the left evaluates to a value that is greater than or equal to the evaluated value of the expression on the right, the "greater than or equal to" operator returns true; otherwise, the operator returns false.

If either expression has a JavaScript type (such as symbols declared with var, function, or external), the "greater than or equal to" operator will additionally - at runtime - convert the values of the expressions to the same type before comparing the values of the results.

Examples

Comparing Values
1
2
3
4
5
6
import System;
 
int a = 1, b = 1, c = 2, d = 3;
Console.log(a >= b); // true
Console.log(b >= c); // false
Console.log(d >= c); // true
Comparing Values in an 'if' statement
1
2
3
4
5
6
7
8
9
10
import System;
 
int x = 2;
 
if (x >= 1) {
    Console.log("x is greater than or equal to 1");
}
else {
    Console.log("x is not greater than or equal to 1");
}

See Also

Share

HTML | BBCode | Direct Link