number

number — A primitive number.

Description

number

Examples

Example #1 – number
var a = 1; var b = new Number(1); console.log(typeof a); // number console.log(typeof b); // object console.log(a); // 1 console.log(b); // Number {1} console.log(a.toFixed(2)); // 1.00 console.log(b.toFixed(2)); // 1.00
Example #2 – number
var a = 1.5; var b = new Number(1.5); a.x = 2; b.x = 2; console.log(a); // 1.5 console.log(b); // Number {1.5, x: 2} console.log(a.x); // undefined console.log(b.x); // 2 console.log(a.toFixed(2)); // 1.50 console.log(b.toFixed(2)); // 1.50

See also

External references