JavaScript: Number Comparison Operators

By Xah Lee. Date: . Last updated: .

Greater Than, Less Than

greater than:

console.log(4 > 3);
// does automatic type conversion
console.log(4 > "3");

less than:

console.log(3 < 4);
// does automatic type conversion
console.log(3 < "4");

greater or equal:

console.log(3 >= 3);
// does automatic type conversion
console.log(3 >= "3");

less or equal:

console.log(3 <= 4);
// does automatic type conversion
console.log(3 <= "4");

test equality:

console.log(3 == "3");
// note: double-equal does automatic type conversion

console.log((3 === "3") === false);
// triple-equal does not do type conversion

test inequality:

console.log(3 != 4);
// The 「!=」 is the negation of double-equal

console.log(3 !== 4);
// The 「!==」 is the negation of triple-equal

Difference Between Double-Equal and Triple-Equal

Equality

JavaScript Operators

BUY
ΣJS
JavaScript in Depth

JavaScript in Depth

Basic Syntax

Value Types

Variable

String

Property

Object and Inheritance

Array

Function

Constructor/Class

Iterable 🌟

Misc