JavaScript Math.log()
The Math.log(x) method used to returns the natural logarithm of a number.
Syntax
Math.log(x)
Here, log() is a static method. Hence, we use it as Math.log().
Parameters- x - (Required).A number.
- Number - The natural logarithm of the number.
- NaN - if the number is less than 0.
- -Infinity - if the number is 0.
Example
console.log(Math.log(1)); //0 console.log(Math.log(10)); //2.302585092994046 console.log(Math.log(3)); //1.0986122886681096 console.log(Math.log(-5)); //NaN console.log(Math.log(0)); //-InfinityTry it Yourself