Math.PI

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Math.PI プロパティは、円周と直径の比率、およそ 3.14159 を表します。

試してみましょう

function calculateCircumference(radius) {
  return 2 * Math.PI * radius;
}

console.log(Math.PI);
// Expected output: 3.141592653589793

console.log(calculateCircumference(10));
// Expected output: 62.83185307179586

𝙼𝚊𝚝𝚑.𝙿𝙸=π3.14159\mathtt{Math.PI} = \pi \approx 3.14159
Math.PI のプロパティ属性
書込可能不可
列挙可能不可
設定可能不可

解説

PIMath オブジェクトの静的プロパティなので、 Math オブジェクトを生成してプロパティとして使用するのではなく、常に Math.PI として使用するようにしてください (Math はコンストラクターではありません)。

Math.PI の使用

次の関数は Math.PI を使用して、指定された半径を持つ円の円周を計算します。

js
function calculateCircumference(radius) {
  return Math.PI * (radius + radius);
}

calculateCircumference(1); // 6.283185307179586

仕様書

Specification
ECMAScript® 2025 Language Specification
# sec-math.pi

ブラウザーの互換性

関連情報