Languages
[Edit]
EN

JavaScript - Math.ln() method example

9 points
Created by:
p_agon
589

There is no Math.ln() method in JavaScript.

Quick solution:

To calculate the natural logarithm use Math.log() method that uses base e 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

  1. JavaScript - Math.log() - Dirask Docs 
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

JavaScript - math (popular problems)

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join