English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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.
Math.log(x)
Math.log(-1; // NaN, out of range Math.log(0);// -Infinity Math.log(1;// 0 Math.log(10; // 2.302585092994046Test See‹/›
All browsers fully support the Math.log() method:
Method | |||||
Math.log() | Yes | Yes | Yes | Yes | Yes |
Parameter | Description |
---|---|
x | Value |
Return Value: | The natural logarithm of a given number (base e). If the number is negative, it returnsNaN |
---|---|
JavaScript Version: | ECMAScript 1 |