JS: Number

By Xah Lee. Date: . Last updated: .

Number Type

Number is a type of Primitive Value

No Distinction of Integer and Float

In js, there is no distinction of integer and float. They are just number type.

console.log(typeof 3 === "number");
// true

console.log(typeof 3.2 === "number");
// true

Decimal Number Syntax

console.log( 123 )
console.log( 123. )
console.log( 123.0 )
console.log( 123.45 )

Number Separator

Numbers can have separator lowline _ between digits.

console.log(1_000 === 1000);

Input Binary, Hexadecimal, Octal, Scientific

NaN and Infinity

Number value also includes NaN and Infinity

JavaScript. Number

JavaScript. Convert Decimal, Hexadecimal, Binary