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:
// ONLINE-RUNNER:browser;
// x y
console.log( Math.log( 1 ) ); // 0 <--- ln(1)
console.log( Math.log( 7 ) ); // 1.9459101490553132 <--- ln(7)
console.log( Math.log( 10 ) ); // 2.3025850929940460 <--- ln(10)
console.log( Math.log( 100 ) ); // 4.6051701859880920 <--- ln(100)
console.log( Math.log( 1000 ) ); // 6.9077552789821370 <--- ln(1000)
console.log( Math.log( -1 ) ); // NaN <--- ln(-1)
console.log( Math.log( 0 ) ); // -Infinity <--- ln(0)
console.log( Math.log( +Infinity ) ); // +Infinity <--- ln(+Infinity)
console.log( Math.E ); // 2.718281828459045
References
- JavaScript - Math.log() - Dirask Docs