JavaScript Math.log()

Examples

let x = Math.log(2);
Try it Yourself »
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 »

Description

The Math.log() method returns the natural logarithm (base E) of a number.




Syntax

Math.log(x)

Parameters

Parameter Description
x Required.
A number.

Return Value

Type Description
NumberThe natural logarithm of the number.
NaN if the number is negative.
-Infinity if the number is 0.


Browser Support

Math.log() is an ECMAScript1 (ES1) feature.

ES1 (JavaScript 1997) is fully supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.