English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript Math.log() Method

 JavaScript Math Object

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

The JavaScript Math.log() function is mathematically equivalent toln(x).

If the passed parameter is negative, the return value is always NaN.

If the passed parameter is 0, the return value is always-Infinity.

Since log() is a static method of Math, you always use it asMath.log(), rather than as a method of the created Math object.

Syntax:

Math.log(x)
Math.log(-1;   // NaN, out of range
Math.log(0);// -Infinity
Math.log(1;// 0
Math.log(10;   // 2.302585092994046
Test See‹/›

Browser Compatibility

All browsers fully support the Math.log() method:

Method
Math.log()YesYesYesYesYes

Parameter Value

ParameterDescription
xValue

Technical Details

Return Value:The natural logarithm of a given number (base e). If the number is negative, it returnsNaN
JavaScript Version:ECMAScript 1

 JavaScript Math Object