JavaScript Math.log()
Examples
let x = Math.log(2);
Try it Yourself »
let a = Math.log(-0);
let b = Math.log(0);
let c = Math.log(-1);
let d = Math.log(1);
let e = Math.log(10);
let f = Math.log(Infinity);
let g = Math.log(-Infinity);
Try it Yourself »
Description
The Math.log()
method returns the natural logarithm (base E) of a number.
JavaScript Logarthmic Functions:
The Math.log() MethodThe Math.log2() Method
The Math.log10() Method
The Math.log1p() Method
Logarthmic Properies:
The Math.LN2 PropertyThe Math.LN10 Property
The Math.LOG2E Property
The Math.LOG10E Property
Exponential Functions:
The Math.E Property (Euler's Number)The Math.exp() Method
The Math.expm1() Method
Syntax
Math.log(x)
Parameters
Parameter | Description |
x | Required. A number. |
Return Value
Type | Description |
Number | The natural logarithm of the number.NaN if the number is negative.-Infinity if the number is 0. |
Browser Support
Math.log()
is an ECMAScript1 (JavaScript 1997) feature.
It is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |