log

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

Applies to

Math

Syntax

log(x)

Parameters

x

A number.

Description

If the value of number is outside the suggested range, the return value is always -1.797693134862316e+308.

log is a static method of Math. As a result, you always use it as Math.log(), rather than as a method of a Math object you create.

Examples

The following function returns the natural log of the variable x:

function getLog(x) {
      return Math.log(x)
}

If you pass getLog the value 10, it returns 2.302585092994046; if you pass it the value 0, it returns -1.797693134862316e+308 because 0 is out of range.

See also

Math.exp, Math.pow