EN
JavaScript - Math.ln() method example
9 points
There is no Math.ln()
method in JavaScript.
Quick solution:
To calculate the natural logarithm use
Math.log()
method that uses basee
as default.
Practical example:
xxxxxxxxxx
1
// x y
2
console.log( Math.log( 1 ) ); // 0 <--- ln(1)
3
console.log( Math.log( 7 ) ); // 1.9459101490553132 <--- ln(7)
4
console.log( Math.log( 10 ) ); // 2.3025850929940460 <--- ln(10)
5
console.log( Math.log( 100 ) ); // 4.6051701859880920 <--- ln(100)
6
console.log( Math.log( 1000 ) ); // 6.9077552789821370 <--- ln(1000)
7
8
console.log( Math.log( -1 ) ); // NaN <--- ln(-1)
9
console.log( Math.log( 0 ) ); // -Infinity <--- ln(0)
10
console.log( Math.log( +Infinity ) ); // +Infinity <--- ln(+Infinity)
11
12
13
console.log( Math.E ); // 2.718281828459045
- JavaScript - Math.log() - Dirask Docs