Number

Literal 15


console.log(15); // decimal
console.log(017); // octal
console.log(0o17); // octal ecma6
console.log(0o17); // octal
console.log(0b1111); // binary ecma6
console.log(0b1111); // binary ecma6
console.log(0xf); // hexa
console.log(0xf); // hexa
console.log(0xf); // hexa
console.log(-15); // negative

Pattern


[(+|-)][digits][.digits][(E|e)[(+|-)]digits]

Number

Reference: JSON ORG

console.log(3.1); //=> 3.1
console.log(3.14); //=> 3.14
console.log(-3.14); //=> -3.14
console.log(0.14); //=> 0.14
console.log(-0.14); //=> -0.14
console.log(3.1e-12); //=> 0.0000000000031
console.log(3.1e12); //=> 3100000000000
console.log(-3.1e12); //=> -3100000000000

IEEE 754


console.log(1.4 - 1.2); //=> 0.19999999999999996

Max Safe Integer


console.log(Number.MAX_SAFE_INTEGER); //=> 9007199254740991 (2**53-1)
console.log(Number.MAX_SAFE_INTEGER + 1); //=> 9007199254740992
console.log(Number.MAX_SAFE_INTEGER + 2); //=> 9007199254740992

BigInt

const max = BigInt(Number.MAX_SAFE_INTEGER);
console.log(max); //=> 9007199254740991n
console.log(max + 1n); //=> 9007199254740992n
console.log(max + 2n); //=> 9007199254740992n

const max = 2n ** (64n - 1n) - 1n;
console.log(max); //=> 9223372036854775807n
console.log(max + 1n); //=> 9223372036854775808n

Reference