--- title: Math.log10() slug: Web/JavaScript/Reference/Global_Objects/Math/log10 tags: - ECMAScript 2015 - JavaScript - Math - Method - Reference translation_of: Web/JavaScript/Reference/Global_Objects/Math/log10 ---
Math.log10()
Funktion gibt den Logarithmus zur Basis 10
zurück. Das bedeutetMath.log10(x)
x
Den Logarithmus zur Basis 10 der gegebenen Zahl. Wenn die Zahl negativ ist, wird {{jsxref("NaN")}} zurückgegeben.
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 {{jsxref("Math.LOG10E")}} welche 1 / {{jsxref("Math.LN10")}} ist.
Math.log10()
Math.log10(2); // 0.3010299956639812 Math.log10(1); // 0 Math.log10(0); // -Infinity Math.log10(-2); // NaN Math.log10(100000); // 5
Diese Funktion kann folgendermaßen emitiert werden:
Math.log10 = Math.log10 || function(x) {
return Math.log(x) * Math.LOG10E;
};
Spezifikation | Status | Kommentar |
---|---|---|
{{SpecName('ES2015', '#sec-math.log10', 'Math.log10')}} | {{Spec2('ES2015')}} | Initiale Definition. |
{{SpecName('ESDraft', '#sec-math.log10', 'Math.log10')}} | {{Spec2('ESDraft')}} |
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.
{{Compat("javascript.builtins.Math.log10")}}