JavaScript Number Type

Comparison

We can compare two numbers and determine equality and inequality. We can also use the less-than and greater-than operators to find the largest or smalles number. All of these operators return a Boolean value.

We determine equality with the value equality operator == or the value and type equality operator ===. Inequality have their own counter parts: != and !==. We recommend always using === as the behavior is more predictable than loose equality.

Code example: equality/inequality

const a = 123
const b = 123
const c = 345
console.log(a === b) // true
console.log(a === c) // false
console.log(a !== c) // true

Code example: less-than/greater-than

const a = 123
const b = 345
console.log(a < b) // true
console.log(a > b) // false