JavaScript log () method
Definition and Usage
log () method returns a number of the natural logarithm (based on E).
NOTE: If x is negative, return NaN.
NOTE: If x is 0, returns -Infinity.
Browser Support
All major browsers support log () method
grammar
Math.log( x )
Parameter Value
参数 | 描述 |
---|---|
x | 必需。任意数值或表达式。 |
return value
类型 | 描述 |
---|---|
Number | x 的自然对数。 |
technical details
JavaScript version: | 1.0 |
---|
More examples
Examples
In this example, we will use a different number of log ():
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);
var b=Math.log(2);
var c=Math.log(1);
var d=Math.log(0);
var e=Math.log(-1);
a, b, c, d, and e output:
1.0000066849139877
0.6931471805599453
0
-Infinity
NaN
0.6931471805599453
0
-Infinity
NaN
try it"