Open In App

JavaScript Number Reference

JavaScript Numbers are always stored in double-precision 64-bit binary format IEEE 754. The types of number literals You can use decimal, binary, octal, and hexadecimal.

Syntax:



Number(object)




function func() {  
    // Original string
    let a = true;
      
    let value = Number(a);
    console.log(value);
}
func();

Output

1

The complete list of JavaScript Numbers is listed below:



JavaScript Number Constructor: In JavaScript, a constructor gets called when an object is created using the new keyword.

Constructor Description Example
Number() Returns the number format for any type of javascript variable.
Try

JavaScript Number Properties: A JavaScript property is a member of an object that associates a key with a value. There are two types of Number properties in JavaScript.

Static Properties Description Example
EPSILON Shows the difference between 1 and the smallest floating point number which is greater than 1.
Try
MAX_SAFE_INTEGER Represents the maximum safe integer.
Try
MAX_VALUE Represent maximum numeric values.
Try
MIN_SAFE_INTEGER Represents the minimum safe integer.
Try
MIN_VALUE Represent minimum numeric values.
Try
NaN Represents a value that is not a valid number.
Try
NEGATIVE_INFINITY Represents the largest negative value i.e negative infinity.
Try
POSITIVE_INFINITY Represents the largest positive value i.e positive infinity.
Try
Instance Properties Description Example
constructor Return the number constructor function for the object.
Try

JavaScript Number Methods: JavaScript methods are the actions that can be performed on objects. There are types of Number methods in JavaScript.

Static Methods Description Example
isNaN() Determine whether the passed value is NaN(Not a Number) and is of the type “Number”.
Try
isFinite() Check whether the passed value is a finite number or not.
Try
isInteger() Returns true if the passed value is an integer, otherwise false.
Try
isSafeInteger() Check the provided value is a number that is a safe integer.
Try
parseFloat() Accept the string and convert it into a floating-point number.
Try
parseInt() Manipulate numbers whether it is negative or positive.
Try
Instance Methods Description Example
toExponential() Returns a string representing the Number object in exponential notation.
Try
toFixed() Format a number using fixed-point notation.
Try
toLocaleString() Converts a number into a string, using a local language format.
Try
toPrecision() Format a number to a specific precision or length.
Try
toString() Return a string representing the specified Number object.
Try
valueOf() Return the primitive value of a number.
Try

Article Tags :