JavaScript log() Method
More "Try it Yourself" examples below.
Definition and Usage
The log() method returns the natural logarithm (base E) of a number.
Browser Support
Method | |||||
---|---|---|---|---|---|
log() | Yes | Yes | Yes | Yes | Yes |
Syntax
Math.log(x)
Parameter Values
Parameter | Description |
---|---|
x | Required. A number |
Technical Details
Return Value: | A Number, representing the natural logarithm of a specified number If the number negative, NaN is returned If the number is 0, -Infinity is returned |
---|---|
JavaScript Version: | ECMAScript 1 |
More Examples
Example
Use the log() method on 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);
Try it Yourself »