JavaScript Tutorial/Math/PI

Материал из Web эксперт
Перейти к: навигация, поиск

Math.PI

The PI property of the Math object is used to get the constant PI.

This is approximately 3.14159.



   <source lang="javascript">

<html>

   <body>
   <script language="JavaScript">
   
   </script>
   <form name=form1>
   The Approximate value of PI is:
   <input type="text" name="answer" size=20>
   <input type="button" value="Calculate" onClick="doMath()">
   
</form> </body> </html></source>

The value of the constant PI: Math.PI

   <source lang="javascript">

<html> <head> <title>The Properties of the Math object</title> <script type="text/javascript" language="javascript">

</script> </head> <body onload="DisplayMath()"> </body> </html></source>


Use Math.PI to do calculation

   <source lang="javascript">

<html> <head> <title>Find the area and circumference of a circle</title> <script type="text/javascript" language="javascript">

</script> </head> <body onload="FindArea()"> </body> </html></source>