Javascript examples for Math:log
The log() method returns the natural logarithm (base E) of a number.
If the parameter x is negative, NaN is returned.
If the parameter x is 0, -Infinity is returned.
Math.log(x)
Parameter | Description |
---|---|
x | Required. A number |
A Number, representing the natural logarithm of a specified number
The following code shows how to return the natural logarithm of the number "2":
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*w w w . j av a 2 s . c o m*/ document.getElementById("demo").innerHTML = Math.log(2); } </script> </body> </html>