Skip to main content Accessibility Feedback

Numbers

Comparisons

JavaScript includes a handful of comparison operators:

Operator Action
> Greater than
< Less than
=== Equals
!== Does not equal
>= Greater than or equal to
<= Less than or equal to
// Greater than
// logs true
console.log(2 > 1);

// Less than
// logs false
console.log(2 < 1);

// Equals
// logs true
console.log(2 === 2);

// Does not equal
// logs true
console.log(2 !== 1);

// Greater than or equal to
// logs true
console.log(2 >= 1);

// Less than or equal to
// logs true
console.log(2 <= 2);

Preorder my new course on Web Components! Want to learn how to build Web Components from scratch, master best practices, and more? Preorder today and get $100 off of the launch price.


Find this useful? You can support my work by purchasing an annual membership.