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.

logarithm()

Type above to see the result…

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

Related functions

© 2026 Heifara Buval