Javascript Number

The Number object is a wrapper object which allows you to work with numerical values. The number object is created using the Number() constructor.It may be integer or floating-point. Syntax

var n=new Number(value);


<!DOCTYPE html>  
var x=100;//integer value  
var y=100.7;//floating point value  
var z=12e5;//exponent value, output: 1200000  
var n=new Number(20);//integer value by number object    
document.write(x+" "+y+" "+z+" "+n);  
Try Now Output
100 100.7 1200000 20
Description The primary uses of the number object are:
  • If argument cannot be converted into a number, it returns NaN (Not a Number).
  • In a non-constructor context (i.e., without the new operator), Number can be used to perform a type conversion.

JavaScript Number Constants

Constant Description
MIN_VALUE It returns the largest minimum value.
MAX_VALUE It returns the largest maximum value.
POSITIVE_INFINITY It returns the positive infinity, overflow value.
NEGATIVE_INFINITY It returns the negative infinity, overflow value.
NaN It represent "Not a Number" value.