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.

La propriété Math.PI représente le ratio entre le périmètre d'un cercle et son diamètre. Elle vaut environ 3.14159:

Math.PI=π3.14159\mathtt{\mi{Math.PI}} = \pi \approx 3.14159

Exemple interactif

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

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

console.log(calculateCircumference(10));
// Expected output: 62.83185307179586
Attributs de Math.PI
ÉcrivableNon
ÉnumérableNon
ConfigurableNon

Description

PI est une propriété statique de l'objet Math et doit toujours être utilisée avec la syntaxe Math.PI plutôt que d'être appelée comme la propriété d'un autre objet qui aurait été crée (Math n'est pas un constructeur).

Exemples

Utiliser Math.PI

La fonction suivante utilise Math.PI afin de calculer le périmètre d'un cercle à partir du rayon passé en argument.

js
function calculPérimètre(rayon) {
  return 2 * Math.PI * rayon;
}

calculPérimètre(1); // 6.283185307179586

Spécifications

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

Compatibilité des navigateurs

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
PI

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

Voir aussi