How to get Natural logarithm of 2 in JavaScript?

JavascriptWeb DevelopmentFront End Technology

<p style="">To get the Natural logarithm of 2, use the Math.LN2 property in JavaScript. It returns the natural logarithm of 2, which is approximately 0.693.</p><h2>Example</h2><p style="">You can try to run the following code to get Natural logarithm of 2 &minus;</p><p><a href="http://tpcg.io/tsYozK" rel="nofollow noopener noreferrer" target="_blank">Live Demo</a></p><pre class="prettyprint notranslate">&lt;html&gt; &nbsp; &nbsp;&lt;head&gt; &nbsp; &nbsp; &nbsp; &lt;title&gt;JavaScript Math LN2 Property&lt;/title&gt; &nbsp; &nbsp;&lt;/head&gt; &nbsp; &nbsp;&lt;body&gt; &nbsp; &nbsp; &nbsp; &lt;script&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var property_value = Math.LN2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;document.write(&quot;Property Value is : &quot; + property_value); &nbsp; &nbsp; &nbsp; &lt;/script&gt; &nbsp; &nbsp;&lt;/body&gt; &lt;/html&gt;</pre><h2>Output</h2><pre class="result notranslate">Property Value is : 0.6931471805599453</pre>
raja
Updated on 18-Jun-2020 08:26:00

Advertisements