Home >>Javascript Tutorial >JavaScript Number

JavaScript Number

JavaScript Number Object

The Number Object in JavaScript authorizes us to represents a numeric value. The numeric value can be an integer or floating-point. The Number Object in JavaScript follows the IEEE standard in order to represent the floating-point numbers.

We can create the number object in JavaScript by the help of Number () Constructor.

Lets understand it with an example:

var n=new Number(value);  

It returns NaN(Not a Number) that can be checked by isNaN () method only if the value can’t be converted to a number.

We can also assign a number to a variable directly, let’s take this example to understand it better:

var a=101;//integer value  
var b=50.7;//floating point value  
var c=12e4;//exponent value, output: 120000  
var z=new Number(20);//integer value by number object

Number Constants in JavaScript

Following is the list of Number Constants in JavaScript along with a brief description:

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

Number Methods in JavaScript

Following is the list of Number Methods in JavaScript along with a brief description

Methods Description
isFinite() This method governs whether the provided value is a finite number.
isInteger() This method governs whether the provided value is an integer.
parseFloat() This method converts the provided string into a floating point number.
parseInt() This method transforms the provided string into an integer number.
toExponential() This method returns the string that depicts the exponential notation of the given number.
toFixed()() This method returns the string that depicts a number with exact digits after a decimal point.
toPrecision() This method returns the string depicting a number of specified precision.
toString() This method returns the provided number in the form of a string.

No Sidebar ads