JavaScript LOG

The JavaScript LOG function is a Math function used to calculate the logarithmic value of a given number with base E. The syntax of the JavaScript LOG Function is


Number: It can be a number or a numerical expression, and it represents the exponent value.

  • If the number argument is a positive value, the LOG function returns the output.
  • When the number is Negative number or not a number, the LOG function returns NaN (Not a Number).
  • If the number argument is Null, the JavaScript logarithmic function changes the Null value to Zero.
  • If it is Zero, the LOG function will return Negative Infinity.

JavaScript LOG Function Example

In this example, We are going to find the JavaScript logarithmic value of different data types and display the output

<!DOCTYPE html>
    <title> JavaScript LOG Function </title>
  <h1> JavaScript LOG Function </h1>
  <p id = "Pos"></p>
  <p id = "Zero"></p>
  <p id = "Dec"></p>
  <p id = "Neg_Dec"></p>
  <p id = "Str"></p>
  <p id = "Exp"></p>
  <p id = "Null"></p>
  <p id = "Multi"></p>
    document.getElementById("Pos").innerHTML = Math.log(1);
    document.getElementById("Zero").innerHTML = Math.log(0);
    document.getElementById("Dec").innerHTML = Math.log(10.45);
    document.getElementById("Neg_Dec").innerHTML = Math.log(-6.45);
    document.getElementById("Str").innerHTML = Math.log("JavaScript");
    document.getElementById("Null").innerHTML = Math.log(null);
    document.getElementById("Multi").innerHTML = Math.log(2 + 7 - 5);
JavaScript LOG Function