Returns the natural logarithm (base E) of a number.
Method of Math
Static
Syntax
log( x )
Parameters
Parameter | Description |
---|---|
x | A number |
Description
If the value of number is negative, the return value is always NaN.
Because log is a static method of Math, you always use it as Math.log(), rather than as a method of a Math object you created.
Examples
The following function returns the natural log of the variable x:
If you pass getLog the value 10, it returns 2.302585092994046; if you pass it the value 0, it returns -Infinity; if you pass it the value -1, it returns NaN because -1 is out of range.