JavaScript logarithm

Math.log() returns the natural logarithm (base e) of a number. Pass 0 and you get -Infinity; pass a negative number and you get NaN.

Syntax

Math.log(num)

Examples

Input Arguments Output
1 0

Gotchas

  • For base-10 or base-2 use Math.log10() or Math.log2().

Try it live

Type your input and see logarithm transform it instantly.

Description: Returns the natural logarithm of a number.

Example: logarithm of 1 => 0

Want to go further? Chain logarithm with other functions in the visual Playground — pipe one output into the next and watch your data transform.

Related functions

© 2026 Heifara Buval