Math.log()
JavaScript 1.0+, ECMAScript 1.0+, JScript 1.0+ Nav2+, NES2+, IE3+, Opera3+ Syntax
math.log(num)
Description
The log() method of the Math object is used to calculate the natural logarithm (base E) of a number.
Example
Listing 6.163 shows how the log() method is used.
Listing 6.163 Example of the log() Method
<html> <body> <script language="JavaScript"> <!–– Hide function doMath(){ var inputNum=document.form1.input.value; var result = Math.log(inputNum); document.form1.answer.value = result; } // End Hide ––> </script> <form name=form1> This example calculates the natural log of the number entered. <br><br> Enter First Number: <input type="text" name="input" size=15> <input type="button" value="Calculate" onClick='doMath()'> ... |
Get Pure JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.