What does log in javascript mean?

WBOY
Release: 2021-12-07 11:47:53
Original
3525 people have browsed it

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".

What does log in javascript mean?

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)
Copy after login

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>
Copy after login

Output result:

What does log in javascript mean?

##[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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!