JavaScript Greater Than or Equal Operator(>=) is used to compare two operands and return true if the left operand has a value greater than or equal to the right operand. The algorithm used in the comparison is similar to that of less than comparison the only difference is that the values are swapped and equal values are checked before returning a boolean.
Syntax:
a>=b
Example 1: In this example, we will compare String, Number, and Boolean using Greater Than or Equal Operator.
Javascript
console.log( "3" >=2); console.log( "2" >=3); console.log( true >= false ); console.log( "3" >= "2" ); console.log(3>=2); |
Output: The values are converted to the same data type and then compared. Here true is treated as one and false as 0. Therefore true is greater than false.
true false true true true
Example 2: In this example, we will use the greater than or equal operator on BigInt and other data types.
Javascript
console.log(2n>=2); console.log(5n>=4); console.log(undefined>= null ); console.log( null >=undefined) |
Output:
true true false false
Supported Browsers:
- Chrome
- Edge
- Firefox
- Opera
- Safari
We have a complete list of JavaScript Comparison Operators, to check those please go through, the JavaScript Comparison Operator article