JavaScript Math.PI Property
Math.PI is the ratio of a circle's circumference to its diameter, approximately 3.14159.
Description
The Math.PI static property represents the ratio of the circumference of a circle to its diameter, π, approximately 3.141592653589793. It's used for circle and angle calculations, including converting degrees to radians: degrees * Math.PI / 180. Like all Math constants, it is read-only.
Because π is irrational, Math.PI is the closest value a JavaScript number can hold, accurate to about 15 decimal places, which is far more than any visual or everyday calculation needs. Results that involve it, such as Math.sin(Math.PI), can be a tiny number instead of exactly zero, so round before comparing or displaying.
In CSS, angles can be written in degrees directly, but JavaScript's trigonometric functions and the Canvas API's arc() method use radians, so Math.PI appears in most drawing code: a full circle is 2 * Math.PI.
Syntax
Math.PIValue
About 3.14159.
Example
Browser Support
The following information will show you the current browser support for the Math.PI property. Hover over a browser icon to see the version that first introduced support for this property.
Desktop





Tablets & Mobile





