Skip to content
Related Articles

Related Articles

JavaScript Number constructor Property
  • Last Updated : 26 Oct, 2020

Below is the example of the Number constructor property.

  • Example:
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html> 
    <html>  
      
    <body style="text-align:center;"
        <h2
            Welcome to GeeksforGeeks 
        </h2
          
        <p
            Click the button to see number 
            contructor property. 
        </p
          
        <button onclick="myGeeks()"
            click me 
        </button
          
        <p id="GFG" style="font-size:20px;" ></p
          
        <!--Script to use Number constructor property-->
        <script
            function myGeeks() { 
                var num = 420;
                  
                document.getElementById("GFG").innerHTML 
                        = num.constructor; 
            
        </script
    </body
      
    </html>                     
                                                 

    chevron_right

    
    

  • Output:
    • Before Clicking On Button:
    • After Clicking On Button:

The Number constructor Property in Javascript is used to return the number constructor function for the object. The function which is returned by this property is just the reference to this function not a number containing the function’s name. The JavaScript number constructor, string constructor and boolean constructor returns function Number() { [native code] }, function String() { [native code] } and function Boolean() { [native code] } respectively.

Syntax:

number.constructor

Return Value: This function returns the Number() { [native code].

More example codes for the above property are as follows:
Program 1:



filter_none

edit
close

play_arrow

link
brightness_4
code

<script
    var num = 444; 
    document.write(num.constructor);
</script

chevron_right


Output:

function Number() { [native code] }

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<script
    var num = 44.44; 
    document.write(num.constructor);
</script

chevron_right


Output:

function Number() { [native code] }

Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :