Die Funktion Math.pow()
gibt die Potenz der Basis
mit dem Exponenten
an
(BasisExponent
)
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.
Syntax
Math.pow(Basis, Exponent)
Parameter
Basis
- Basis (auch: die Grundzahl).
Exponent
- der Exponent (auch: die Hochzahl).
Rückgabewert
Eine Zahl, die die Basis potenziert mit dem Exponenten repräsentiert.
Beschreibung
Weil pow()
eine statische Funktion von Math
ist, wird es immer als Math.pow()
eingesetzt,
jedoch nicht als Methode eines erzeugten Math
Objektes (Math
ist kein Konstruktor).
Beispiele
Benutzung von Math.pow()
// einfach Math.pow(7, 2); // 49 Math.pow(7, 3); // 343 Math.pow(2, 10); // 1024 // Brüche als Exponenten Math.pow(4, 0.5); // 2 (Wurzel aus 4) Math.pow(8, 1/3); // 2 (Kubikwurzel aus 8) Math.pow(2, 0.5); // 1.4142135623730951 (Wurzel aus 2) Math.pow(2, 1/3); // 1.2599210498948732 (Kubikwurzel aus 2) // Negative Exponenten Math.pow(7, -2); // 0.02040816326530612 (1/49) Math.pow(8, -1/3); // 0.5 // Negative Basis Math.pow(-7, 2); // 49 (Das Quadrat ist positiv) Math.pow(-7, 3); // -343 (kann negativ sein) Math.pow(-7, 0.5); // NaN (negative Zahlen haben keine Quadratwurzel) // auch wegen Grenzen bei der Gleitkomma Berechnung, // Negative Basis mit Bruch als Exponent gibt immer NaN zurück Math.pow(-7, 1/3); // NaN
Spezifikationen
Spezifikation | Status | Kommentar |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard |
Initiale Deffinition, Implementiert in JavaScript 1.0. |
ECMAScript 5.1 (ECMA-262) Die Definition von 'Math.pow' in dieser Spezifikation. |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) Die Definition von 'Math.pow' in dieser Spezifikation. |
Standard | |
ECMAScript Latest Draft (ECMA-262) Die Definition von 'Math.pow' in dieser Spezifikation. |
Entwurf |
Browserkompatibilität
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.
Desktop | Mobile | Server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pow | Chrome Vollständige Unterstützung 1 | Edge Vollständige Unterstützung 12 | Firefox Vollständige Unterstützung 1 | IE Vollständige Unterstützung 3 | Opera Vollständige Unterstützung Ja | Safari Vollständige Unterstützung Ja | WebView Android Vollständige Unterstützung 1 | Chrome Android Vollständige Unterstützung 18 | Firefox Android Vollständige Unterstützung 4 | Opera Android Vollständige Unterstützung Ja | Safari iOS Vollständige Unterstützung Ja | Samsung Internet Android Vollständige Unterstützung 1.0 | nodejs Vollständige Unterstützung Ja |
Legende
- Vollständige Unterstützung
- Vollständige Unterstützung