To calculate the ln of a given number, use the Math.log() method in JavaScript. This method returns the natural logarithm (base E) of a number. If the value of a number is negative, the return value is always NaN.
Example
You can try to run the following code to get the ln of a given number −
<html> <head> <title>JavaScript Math log() Method</title> </head> <body> <script> var value = Math.log(2); document.write("Value : " + value ); </script> </body> </html>