A tutorial on using the logarithmic ES1en.log of method in JavaScript

  • 2020-06-15 07:38:35
  • OfStack

This method returns the natural log of 1 number (base E). If the value of the number is negative, the return value is always NaN.
grammar


Math.log( x ) ;

Here is the details of the parameters:

x: One number.

The return value:

Returns the natural log of 1 number (base E).

Example:


<html>
<head>
<title>JavaScript Math log() Method</title>
</head>
<body>
<script type="text/javascript">

var value = Math.log(10);
document.write("First Test Value : " + value ); 
 
var value = Math.log(0);
document.write("<br />Second Test Value : " + value ); 

var value = Math.log(-1);
document.write("<br />Third Test Value : " + value ); 

var value = Math.log(100);
document.write("<br />Fourth Test Value : " + value ); 
</script>
</body>
</html>

This will produce the following results:


First Test Value : 2.302585092994046
Second Test Value : -Infinity
Third Test Value : NaN
Fourth Test Value : 4.605170185988092 


Related articles: