Skip to content
Related Articles
Open in App
Not now

Related Articles

JavaScript Number Complete Reference

Improve Article
Save Article
  • Last Updated : 15 Mar, 2023
Improve Article
Save Article

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)

Javascript




<script>
    function func() {
      
        // Original string
        var a = true;
      
        var value = Number(a);
        console.log(value);
    }
    func();
</script>

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.

ConstructorDescription
Number()Returns the number format for any type of javascript variable.

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 Property: A static property is a property that has the same value for the entire class.

    Static PropertiesDescription
    EPSILONShows the difference between 1 and the smallest floating point number which is greater than 1.
    MAX_SAFE_INTEGERRepresents the minimum safe integer.
    MAX_VALUERepresent minimum numeric values.
    MIN_SAFE_INTEGERRepresents the minimum safe integer.
    MIN_VALUERepresent minimum numeric values.
    NaNRepresents a value that is not a valid number.
    NEGATIVE_INFINITYRepresents the largest negative value i.e negative infinity.
    POSITIVE_INFINITYRepresents the largest positive value i.e positive infinity.
  • Instance Property: An instance property is a property that has a new copy for every new instance of the class.

    Instance PropertiesDescription
    constructorReturn the number constructor function for the object.

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

  • Static Method: If the method is called using the Number class itself then it is called a static method.

    Static MethodsDescription
    isNaN()Determine whether the passed value is NaN(Not a Number) and is of the type “Number”.
    isFinite()Check whether the passed value is a finite number or not.
    isInteger()Returns true if the passed value is an integer, otherwise false.
    isSafeInteger()Check the provided value is a number that is a safe integer.
    parseFloat()Accept the string and convert it into a floating-point number.
    parseInt()Manipulate numbers whether it is negative or positive.
  • Instance Method: If the method is called on an instance of a number then it is called an instance method.

    Instance MethodsDescription
    toExponential()Returns a string representing the Number object in exponential notation.
    toFixed()Format a number using fixed-point notation.
    toLocaleString()Converts a number into a string, using a local language format.
    toPrecision()Format a number to a specific precision or length.
    toString()Return a string representing the specified Number object.
    valueOf()Return the primitive value of a number.

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!