Example 1 — Numbers
Simple ordering.
JavaScript
console.log(10 > 2);
console.log(10 <= 9);How It Works
- 10 is greater than 2.
- 10 is not <= 9.
Relational comparison operators test order: <, >, <=, and >=. They return a boolean. For equality, prefer === (see the equality page).
console.log(3 < 5);
console.log(3 >= 3);
console.log("a" < "b");Simple ordering.
console.log(10 > 2);
console.log(10 <= 9);Mixed types convert to numbers when possible.
console.log("10" > 2);Use the equality operators page for == / ===.
console.log(1 === 1);CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
6 people found this page helpful