Math.log10()
Funktion gibt den Logarithmus zur Basis 10
zurück. Das bedeutetThe 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.log10(x)
Parameter
x
- Eine Zahl.
Rückgabewert
Den Logarithmus zur Basis 10 der gegebenen Zahl. Wenn die Zahl negativ ist, wird NaN
zurückgegeben.
Beschreibung
Wenn der Wert von x
negativ ist, so gibt die Funktion immer NaN
zurück.
Weil log10()
eine statische Funktion von Math
ist, wird es immer als Math.log10()
eingesetzt,
jedoch nicht als Methode eines erzeugten Math
Objektes (Math
ist kein Konstruktor).
Diese Funktion ist äquivalent zu Math.log(x) / Math.log(10). Für log10(e) gibt es die Konstante Math.LOG10E
welche 1 / Math.LN10
ist.
Beispiele
Einsatz von Math.log10()
Math.log10(2); // 0.3010299956639812
Math.log10(1); // 0
Math.log10(0); // -Infinity
Math.log10(-2); // NaN
Math.log10(100000); // 5
Polyfill
Diese Funktion kann folgendermaßen emitiert werden:
Math.log10 = Math.log10 || function(x) {
return Math.log(x) * Math.LOG10E;
};
Spezifikationen
Spezifikation | Status | Kommentar |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) Die Definition von 'Math.log10' in dieser Spezifikation. |
Standard | Initiale Definition. |
ECMAScript (ECMA-262) Die Definition von 'Math.log10' 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.