Log in JavaScript means "logarithm" and is a method of the Math object. The syntax is "Math.log(x)"; the log() method can return the natural logarithm of the number "x". If the parameter value is a negative number, the return result is "NaN". If the parameter value is 0, the return result is "-Infinity".
The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.
What is the meaning of log in JavaScript
log in JavaScript means "logarithm", the log() method returns the natural value of a number Logarithm (base E).
The syntax of this method is as follows:
Math.log(x)
If the parameter x is a negative number, NaN will be returned. If parameter x is 0, then -Infinity is returned. The result returned is the natural logarithm of x.
The example is as follows:
<html> <head> <meta charset="utf-8"> <title>123</title> </head> <body> <p id="demo">单击按钮显示不同数值的自然对数。</p> <button onclick="myFunction()">点我</button> <script> function myFunction(){ var a=Math.log(2.7183); var b=Math.log(2); var c=Math.log(1); var d=Math.log(0); var e=Math.log(-1); var x=document.getElementById("demo"); x.innerHTML=a + "<br>" + b + "<br>" + c + "<br>" + d + "<br>" + e } </script> </body> </html>
Output result:
##[Related recommendations:javascript learning tutorial 】
The above is the detailed content of What does log in javascript mean?. For more information, please follow other related articles on the PHP Chinese website!