JavaScript Math log10 ()

Die JavaScript-Funktion Math.log10 () gibt den Basis-10-Logarithmus einer Zahl zurück.

Dies entspricht log 10 (x) in der Mathematik.

Die Syntax der Math.log10()Funktion lautet:

 Math.log10(x)

log10()Da es sich um eine statische Methode handelt, wird sie mit dem MathKlassennamen aufgerufen .

Math.log10 () Parameter

Die Math.log10()Funktion umfasst:

  • x - Eine Zahl

Rückgabewert von Math.log10 ()

  • Gibt den Logarithmus zur Basis 10 der angegebenen Zahl zurück.
  • Rückgabe NaNfür negative Zahlen und nicht numerische Argumente.

Beispiel: Verwenden von Math.log10 ()

 // Using Math.log10() var value = Math.log10(1); console.log(value); // 0 var value = Math.log10(10000); console.log(value); // 4 var value = Math.log10("10"); console.log(value); // 1 var value = Math.log10(0); console.log(value); // -Infinity var value = Math.log10(-1); console.log(value); // NaN

Ausgabe

 0 4 1 -Infinity NaN

Anmerkungen:

  • Verwenden Sie die Konstante Math.LOG10Efür log 10 (e) .
  • Verwenden Sie die Funktionen Math.log()oder Math.log2()für die Logarithmusbasis e und 2 .

Empfohlene Lektüre:

  • Math.log ()
  • Math.log2 ()

Interessante Beiträge...