How to create a Number object using JavaScript?

JavascriptWeb DevelopmentFront End Technology

The Number object represents a numerical date, either integers or floating-point numbers. The syntax for creating a number object is as follows −

var val = new Number(number);

The Number object without the new operator can be used to perform a type conversion. Let’s see an example of Number.MAX_VALUE property. The Number.MAX_VALUE property belongs to the static Number object.

Example

Live Demo

<html>
   <head>
      <script>
         <!--
            function showValue() {
               var val = Number.MAX_VALUE;
               document.write ("Value of Number.MAX_VALUE : " + val );
            }
         //-->
      </script>
   </head>
   <body>
      <p>Click the following to see the result:</p>
      <form>
         <input type="button" value="Click Me" onclick="showValue();" />
      </form>
   </body>
</html>
raja
Published on 03-Feb-2018 11:29:48
Advertisements