Math.cbrt()
Try it
Die Funktion Math.cbrt()
gibt die Kubikwurzel einer Zahl zurück:
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