Die Math.PI
Eigenschaft repräsentiert die Kreiszahl Pi, welche als Verhältnis zwischen Kreisumfang und Durchmesser definiert ist und gerundet die Zahl 3,14159 ist.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Eigenschaftsattribute von Math.PI |
|
---|---|
Schreibbar | nein |
Aufzählbar | nein |
Konfigurierbar | nein |
Beschreibung
Weil PI
eine statische Eigenschaft von Math
ist, muss immer Math.PI
genutzt werden, ohne dass ein Math
Objekt erstellt wird (Math
ist kein Konstruktor).
Beispiele
Einsatz von Math.PI
Die folgende Funktion benutzt Math.PI
, um aus einem Radius den Umfrang eines Kreises zu berechnen:
function calculateCircumference(radius) {
return Math.PI * (radius + radius);
}
calculateCircumference(1); // 6.283185307179586
Spezifikationen
Spezifikation | Status | Kommentar |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | Initiale Definition. Implementiert in JavaScript 1.0. |
ECMAScript 5.1 (ECMA-262) Die Definition von 'Math.PI' in dieser Spezifikation. |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) Die Definition von 'Math.PI' in dieser Spezifikation. |
Standard | |
ECMAScript (ECMA-262) Die Definition von 'Math.PI' in dieser Spezifikation. |
Lebender Standard |
Browserkompatibilität
BCD tables only load in the browser
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.