log()  Math  class methodS2C Home  « Globals « Math « log()


Returns the natural logarithm of a number (base E).

  • Like all class methods log() should be used on the class rather than an instance of the class.


Signature Description
Math.log(value)Returns the natural logarithm of a number (base E).


Parameter Description
valueThe value you wish to find the log() of:
  • Negative numbers returns NaN.
  • Non-numeric strings returns NaN.
  • Passing no parameter returns NaN.
  • Passing null or 0 returns -Infinity.


The code below displays log() usage.

 * Store results in an array.
var logValues = new Array(5);
logValues[0] = Math.log(-1);
logValues[1] = Math.log(0);
logValues[2] = Math.log('0.75');
logValues[3] = Math.log('a string');
logValues[4] = Math.log();
logValues[5] = Math.log(null);

Press the button below to action the above code:

Related Tutorials

JavaScript Advanced Tutorials - Lesson 4 - Math

go to home page Homepage go to top of page Top