To return the natural logarithm of a number, use the JavaScript Math.log() method. If the value of a number is negative, the return value is always NaN.
Example
You can try to run the following code to get the natural logarithm of a number −
<html>
<head>
<title>JavaScript Math log() Method</title>
</head>
<body>
<script>
var value = Math.log(10);
document.write("First Value : " + value );
var value = Math.log(0);
document.write("<br />Second Value : " + value );
var value = Math.log(-1);
document.write("<br />Third Value : " + value );
var value = Math.log(100);
document.write("<br />Fourth Value : " + value );
</script>
</body>
</html>