Math

Math.PI

Represents the ratio of the circumference of a circle to its diameter, approximately 3.14159

Syntax

JavaScript
Math.PI

Return Value

The number 3.141592653589793

Examples

Basic Usage
console.log(Math.PI); // 3.141592653589793
Practical Example
function circleArea(radius: number) {
  return Math.PI * radius ** 2;
}
console.log(circleArea(5).toFixed(2)); // '78.54'
Advanced Usage
function degreesToRadians(deg: number) {
  return deg * (Math.PI / 180);
}
console.log(degreesToRadians(180)); // ~3.14159

Understanding Math.PI

The Math.PI method in JavaScript represents the ratio of the circumference of a circle to its diameter, approximately 3.14159. It belongs to the Math object and is one of the most widely used methods for working with math values in modern JavaScript and TypeScript applications.

The method signature is Math.PI. When called, it returns the number 3.141592653589793. Understanding when and how to use PI() helps you write more expressive, readable code.

Common use cases for Math.PI include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like math-e, math-sin, math-cos, enabling you to chain operations together for complex data manipulation pipelines.

Browser support for Math.PI is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.

Browser Compatibility

Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.

Related Methods

More Math Methods

Other methods in the Math object

Related Tools

More Math Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.