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.
Want to go further? Chain logarithm with other functions in the visual Playground — pipe one output into the next and watch your data transform.