Math.log method

The Math.log method returns the value of the natural logarithm of a passed number.

Syntax

Math.log(number);

Example

In this example, the value of the natural logarithm of 35 will be displayed:

console.log(Math.log(35));

The code execution result:

3.5553480614894135

Example

In this example, the value of the natural logarithm of -10 will be displayed:

console.log(Math.log(-10));

The code execution result:

NaN

See also

  • the Math.pow method
    that raises a number to a given power
  • the Math.exp method
    that raises the number e to a given power
  • the Math.LN2 property
    that returns the value of the natural logarithm of two
  • the Math.LN10 property
    that returns the value of the natural logarithm of ten
enru