Die Funktion Math.cbrt()
gibt die Kubikwurzel einer Zahl zurück:
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.cbrt(x)
Parameter
x
- Eine Zahl.
Rückgabewert
Die Kubikwurzel der übergebenen Zahl.
Beschreibung
Weil cbrt()
eine statische Methode von Math
ist, muss diese immer mit Math.cbrt()
genutzt werden, ohne dass ein Objekt von Math erstellt wird (Math
ist kein Konstruktor).
Beispiele
Verwendung von Math.cbrt()
Math.cbrt(NaN); // NaN
Math.cbrt(-1); // -1
Math.cbrt(-0); // -0
Math.cbrt(-Infinity); // -Infinity
Math.cbrt(0); // 0
Math.cbrt(1); // 1
Math.cbrt(Infinity); // Infinity
Math.cbrt(null); // 0
Math.cbrt(2); // 1.2599210498948734
Polyfill
Für gilt so dass diese Funktion wie folgt emuliert werden kann:
if (!Math.cbrt) {
Math.cbrt = function(x) {
var y = Math.pow(Math.abs(x), 1/3);
return x < 0 ? -y : y;
};
}
Spezifikationen
Spezifikation | Status | Kommentar |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) Die Definition von 'Math.cbrt' in dieser Spezifikation. |
Standard | Initiale Definition. |
ECMAScript (ECMA-262) Die Definition von 'Math.cbrt' 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.