JavaScript Number Object

A numeric value can be represented using the JavaScript number object. In JavaScript, you may create a number object by using the Number() constructor. Numbers are primitive data types in JavaScript.

Lets take an example

const x = 2;
const y = 1.49;

You may also directly assign a different number to a variable.

var x=2;               //integer number  
var y=101.89;          //floating number  
var z=new Number(23);  //number object integer value

Number Constants

MIN_VALUEreturns the smallest possible value
MAX_VALUEreturns the greatest possible value
POSITIVE_INFINITYreturns a positive infinity, indicating an overflow value
NEGATIVE_INFINITYyields a negative infinity, indicating an overflow value
NaNrepresents the value Not a Number

Number Objects

const x = 15;

// constructing a number object
const y = new Number(15);

console.log(x);         // 45
console.log(y);         // [Number: 15]

console.log(typeof x);  // "number"
console.log(typeof y);  // "object"