Math.PI
The ratio of a circle's circumference to its diameter, approximately 3.14159.
Syntax
Math.PI Returns
number — Approximately 3.141592653589793.
Examples
console.log(Math.PI);
Output
3.141592653589793
const r = 2;
console.log(Math.PI * r * r);
Output
12.566370614359172
Notes
A read-only constant on the Math object. Use it for circle/trigonometry math
and for converting degrees and radians (`deg * Math.PI / 180`).
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 1.0 |
| firefox | 1.0 |
| safari | 1.0 |
| edge | 12 |
| node | 0.10 |