How to calculate the ln of a given number in JavaScript?


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>

Updated on: 19-Jun-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements