Creating Number Objects Rather than Performing String-to-Number Conversions : Number Data Type : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » Number Data Type »

 

Creating Number Objects Rather than Performing String-to-Number Conversions



<html>
<head>
  <script language="JavaScript1.1" type="text/javascript">
  <!--
    Number.prototype.description = null;
   
    Highway = new Number(65);
    City = new Number(35);
    SchoolZone = new Number(25);
   
    Highway.description = "Interstate Highway Speed Limit";
    City.description = "City Speed Limit";
    SchoolZone.description = "School Zone Speed Limit";
   
    function tellDifference(num1, num2) {
      diff = num1 - num2;
      document.write("The speed difference between " + num1.description +
                          " and " + num2.description + " is " + diff);    }
   

  //-->
  </script>
</head>
<body>
  <script language="JavaScript1.1" type="text/javascript">
  <!--
    // Call function
    tellDifference(Highway,  City);
  //-->
  </script>
</body>
</html>



           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Language Basics
» Number Data Type