Use Math.PI to do calculation : PI « Math « JavaScript Tutorial






<html>
<head>
<title>Find the area and circumference of a circle</title>
<script type="text/javascript" language="javascript">
<!-- //
function FindArea(){
    var number = new Number(123);
    document.write("<P>You entered a radius of " + number + "</p>");
    document.write("<P>The area of the circle is " + (number * number * Math.PI) + "</p>");
    document.write("<P>The circumference of the circle is " + (2 * number * Math.PI) + "</p>");
}
// -->
</script>
</head>
<body onload="FindArea()">

</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