Relational Operators

Greater than, less than, etc.

Examples

Number Comparison

Basic number comparison.

console.log(10 > 5); // true
console.log(10 < 5); // false

String Comparison

Strings are compared alphabetically.

console.log("Alpha" < "Beta"); // true
console.log("Apple" > "Banana"); // false

String vs Number

String is converted to number if possible when comparing with number.

console.log("20" > 10); // true (string converted to number)
console.log("01" < 2); // true

Test Your Knowledge

JavaScript Quiz

No quiz available for this topic yet.