constants

Math.PI

The ratio of a circle's circumference to its diameter, approximately 3.141592653589793. A read-only numeric property, not a function.

Math.PI

Parameters & edge cases

Case Behavior
precision Math.PI is a double-precision approximation, not exact π — small trig errors are unavoidable
degrees to radians Multiply degrees by (Math.PI / 180)
radians to degrees Multiply radians by (180 / Math.PI)

Examples

console.log(Math.PI);                    // 3.141592653589793

The stored value.

console.log(Math.PI * 2);                // 6.283185307179586

2π — one full turn in radians (a.k.a. τ).

console.log(180 / Math.PI);              // 57.29577951308232

Degrees per radian — used for radians→degrees conversion.

console.log(Math.PI * r * r);            // area of a circle

Classic πr² formula.

Gotcha

Math.PI is only accurate to ~15-17 decimal digits. Because of that, Math.sin(Math.PI) is ≈1.22e-16, not 0 — never compare trig outputs with strict equality.

Related

← All JS Math methods · Array methods