How to use Math PI Property in JavaScript

In this article, I will explain use of Math PI Property in JavaScript.
  • 2026

JavaScript PI Property

  • PI property of math object returns the ratio of the circumference of a circle to to its diameter which is approximately 3.14159.

Syntax

Math.PI

Example

The following example is show to use of PI property in javascript.

<!DOCTYPE html>

<html>

<body>

<h3>PI Property Example</h3>

<p id="demo" style=" background-color:Blue" >Click the button to display PI Value</p>

<button onclick="myFunction()">Click On</button>

<script type="text/javascript">

    function myFunction() {

        document.getElementById("demo").innerHTML = Math.PI;

    }

</script>

</body>

</html>

Output1

PI output 1.jpg

Output2

PI output final.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.