Search⌘ K
AI Features

Comparison Operators: <, >, <=, >=, ==, ===, !=, !==

Explore JavaScript comparison operators to understand how to compare values using <, >, <=, >=, ==, ===, and their negations. Learn why triple-equal is preferred over double-equal for strict equality checks and how to use these operators effectively in if-statements.

We'll cover the following...

We have more operators to cover, but I promise this is it!

< | >

These two operators are used to compare the value of numbers. They result in true or false and are often used in if-statements. > means greater than and < means less than.

Node.js
if(10 > 5) {
console.log('Condition is true!');
} else {
console.log('Condition is false.');
}
Node.js
if(10 < 5) {
console.log('Condition is true!');
} else {
console.log('Condition is false.');
}

<= | >=

These mean “less than or equal to” and “greater than or equal to” ...

Node.js
if(10 >= 5) {
console.log('Condition is true!');
} else {
console.log('Condition is false.');
}
if(5 >= 5) {
console.log('Condition is true!');
} else {
console.log('Condition is false.');
}
Node.js
if(5 <= 10) {
console.log('Condition is true!');
} else {
console.log('Condition is false.');
}
if(5 <= 5) {
console.log('Condition is true!');
} else {
console.log('Condition is false.');
}
...