JavaScript Math.log()
Definition and Usage
The Math.log() method returns the natural logarithm (base E) of a number.
More Examples
let a = Math.log(2.7183);
let b = Math.log(2);
let c = Math.log(1);
let d = Math.log(0);
let e = Math.log(-1);
Try it Yourself »
Browser Support
Math.log()
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
Syntax
Math.log(x)
Parameters
Parameter | Description |
---|---|
x | Required. A number |
Return Value
A number representing the natural logarithm of the number. If the number is negative, NaN is returned. If the number is 0, -Infinity is returned. |