CKTIS / JavaScript
Math.PI: the number pi
Math.PI is the closest Number representation of π, the ratio of a circle’s circumference to its diameter.
Version: ECMAScript 1 onward; example target: Node.js 24.22.2
Syntax
Math.PIMath.PI is the Number value approximately equal to 3.141592653589793. It approximates the irrational number π in binary64, so calculations inherit ordinary floating-point rounding. It is a data property of the Math object, not a function; it takes no arguments and is not called.
The property has writable: false, enumerable: false, and configurable: false. Assignment does not change it; in strict code an attempted write throws TypeError, and an incompatible redefinition also fails. The constant has been standard since ECMAScript 1.
Use it in formulas involving radians or circle geometry: circumference is 2 * Math.PI * radius, while area is Math.PI * radius ** 2. Compare floating-point results with a scale-appropriate tolerance instead of expecting perfect mathematical equality.
Examples
const radius = 3;
console.log((2 * Math.PI * radius).toFixed(6));
console.log((Math.PI * radius ** 2).toFixed(6));
const descriptor = Object.getOwnPropertyDescriptor(Math, "PI");
console.log(descriptor.writable, descriptor.enumerable, descriptor.configurable);
console.log(Math.PI === 3.141592653589793);Result
18.849556 28.274334 false false false true
Math.PI → circumference 18.849556, area 28.274334