JavaScript log() Method
- Previous Page LN10
- Next Page log10()
- Go to the Previous Level JavaScript Math Reference Manual
Definition and Usage
log()
The method returns the natural logarithm of a number (base E).
Note:If the parameter x If the parameter is negative, it returns NaN.
Note:If the parameter x If the parameter is 0, it returns -Infinity.
Example
Example 1
Returns the natural logarithm of the number "2":
Math.log(2);
Example 2
Use the log() method for different numbers:
var a = Math.log(2.7183); var b = Math.log(2); var c = Math.log(1); var d = Math.log(0); var e = Math.log(-1);
Syntax
Math.log(x)
Parameter Value
Parameter | Description |
---|---|
x | Required. Any number or expression. Must be greater than 0. |
Technical Details
Return Value: | A number representing the natural logarithm of the specified number. |
---|---|
JavaScript Version: | ECMAScript 1 |
Browser Support
Method | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
log() | Support | Support | Support | Support | Support |
Related Pages
Tutorial:JavaScript Math
- Previous Page LN10
- Next Page log10()
- Go to the Previous Level JavaScript Math Reference Manual