JavaScript Math Object : log()

The log() method returns the natural logarithm (base E) of given number, and if the value of number is negative, the return value is always NaN. Syntax :
  Math.log( number );
Example :
<script>
  var x = 5;
  var y = Math.log(x);
  document.write("log(5) : " + y + "<br/>");
  var x = 0;
  var y = Math.log(x);
  document.write("log(0) : " + y + "<br/>");
  var x = -1;
  var y = Math.log(x);
  document.write("log(-1) : " + y + "<br/>");
  var x = 15.75;
  var y = Math.log(x);
  document.write("log(15.75) : " + y + "<br/>");
</script>
Output :


Next Topic :