Easy Tutorial
❮ Dom Obj Menuitem Prop Link Href ❯

JavaScript log() Method

JavaScript Math Object

Example

Return the natural logarithm of 2:

Output result:


Definition and Usage

The log() method returns the natural logarithm (base E) of a number.

Note: If x is negative, it returns NaN.

Note: If x is 0, it returns -Infinity.


Browser Support

All major browsers support the log() method.


Syntax

Parameter Values

Parameter Description
x Required. Any numeric value or expression.

Return Value

Type Description
Number The natural logarithm of x.

Technical Details

| JavaScript Version: | 1.0 | | --- | --- |


More Examples

Example

In this example, we will apply log() to different numbers:

a, b, c, d, and e Output result:


JavaScript Math Object

❮ Dom Obj Menuitem Prop Link Href ❯