Number type

in JavaScript

Unexpected behavior

Infinite loop

for (var i=1; 1/i > 0; i++) {
    console.log("Count is: " + i);
}
Java
JavaScript
for (int i=1; 1/i > 0; i++) {
    System.out.println("Count is: " + i);
}

Fractional numbers addition

0.1 + 0.2 === 0.3 // false

0.1 + 0.2         // 0.30000000000000004

Same numbers comparison

9007199254740992 === 9007199254740993 // true

9007199254740993                      // 9007199254740992

Representing numbers in the scientific notation

Representing numbers in the scientific notation

General form

Number 2 in scientific notation:

significant \times base^{exponent}
significant×baseexponentsignificant \times base^{exponent}

Number type in JavaScript

By maximk

Number type in JavaScript

  • 559