Get the Value of PI with JavaScript | Plantpot

Get the Value of PI with JavaScript

Web Dev
Sponsored links

In this article, I will introduce how to get the value of PI with JavaScript.

The Math.PI property

The Math.PI property returns the ratio of the circumference of a circle to its diameter.

The syntax is below.


// expected output: 3.141592653589793
Sponsored links

Sample Code

Below is a sample code to calculate the area of ​​a circle.

function calculateCircleArea(radius) {
  return radius * radius * Math.PI;

// expected output: 314.1592653589793