Greater-than or Equal-to Operator in JavaScript



Greater-than or Equal-to Comparison Operator

In JavaScript, Greater-than or equal-to comparison operator takes two operands, returns true if value in left side operand is greater than or equal to that of the right operand, or false otherwise.

Syntax

>= symbol is used for comparison greater-than or equal-to operator.

a >= 5  //returns true if a has a value > or == 5
a >= b  //returns true if a has a value > or == b

Examples

1. Check if value in a is greater than or equal to 5.

var a = 8;
if (a >= 5) {
    console.log('a is greater than or equal to 5');
} else {
    console.log('a is not greater than or equal to 5');
}

2. Check if value in a is greater than or equal to that of in b.

var a = 5;
var b = 7;
if (a >= b) {
    console.log('a is greater than or equal to b');
} else {
    console.log('a is not greater than or equal to b');
}