HTML CSS Bootstrap Javascript Icons Python
JavaScript Reference
Overview
JS Reference
JS Array Object JS Boolean Object JS Date Object JS Style Declaration Object JS Error Object JS Global Object JS Math Object JS Number Object JS String Object JS RegExp Object JS Statements
DOM Reference
DOM Attribute DOM Console DOM Document DOM Element DOM Events DOM Event Objects DOM History DOM HTMLCollection DOM Location DOM Navigator DOM Screen DOM Style DOM Window WEB Storage

JavaScript Number Reference

The JavaScript Number object acts as a wrapper for primitive numeric values.

The Number Object

The Number object allows you to work with numbers.

JavaScript has only one kind of number data type and it doesn't distinguish between integers and floating-point values.

Numbers can be written with, or without decimals:

Extra large or extra small numbers can be written with scientific notation:

You can learn more about Numbers in our JavaScript Number Tutorial.


Number Object Properties

The following table lists the properties of the Number object:

Property Description
constructor Returns a reference to the Number function that created the object
MAX_VALUE Returns the largest number possible in JavaScript
MIN_VALUE Returns the smallest number possible in JavaScript
MAX_SAFE_INTEGER Returns the maximum safe integer in JavaScript (253 - 1)
MIN_SAFE_INTEGER Returns the miniimum safe integer in JavaScript (-253 - 1)
NaN Represents a "Not-a-Number" value
NEGATIVE_INFINITY Represents negative infinity (returned on overflow)
POSITIVE_INFINITY Represents infinity (returned on overflow)
prototype Allows you to add properties and methods to an object

Number Object Methods

The following table lists the methods of the Number object:

Method Description
isFinite() Checks whether the passed value is a finite number
isInteger() Checks whether the passed value is an integer
isNaN() Checks whether the passed value is NaN and its type is Number
isSafeInteger() Checks whether a value is a safe integer
toExponential() Converts a number to exponential notation
toFixed() Formats a number using fixed-point notation
toPrecision() Returns a string representing the number to the specified precision
toString() Converts a number to a string
valueOf() Returns the primitive value of a Number object

Note: All number methods return a new value. They do not change the original variable.