Math.PI : PI « Math « JavaScript Tutorial





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

This is approximately 3.14159.

<html>
    <body>
    <script language="JavaScript">
    <!--
    function doMath(){
        var result = Math.PI;
        document.form1.answer.value = result;
    }
    -->
    </script>
    <form name=form1>
    The Approximate value of PI is:
    <input type="text" name="answer" size=20>
    <input type="button" value="Calculate" onClick='doMath()'>
    <br>
    </form>
    </body>
    </html>










9.19.PI
9.19.1.Math.PI
9.19.2.The value of the constant PI: Math.PI
9.19.3.Use Math.PI to do calculation