JavaScript log1p() method

Definition and usage

log1p() The method returns 1 + the natural logarithm (base E) of the specified number.

Example

Returns 1 + the natural logarithm (base E) of different numbers:

var a = Math.log1p(2.7183);
var b = Math.log1p(2);
var c = Math.log1p(1);
var d = Math.log1p(0);
var e = Math.log1p(-1);

Try it yourself

Syntax

Math.log1p(x)

Parameter value

Parameter Description
x Required. Number.

Technical details

Return value:

A number representing the natural logarithm (base E) of 1 + the specified number

  • If the number is -1, it returns -Infinity
  • If the number is less than -1, it returns NaN
JavaScript Version: ECMAScript 2015

Browser Support

Method Chrome Edge Firefox Safari Opera
log1p() 38.0 12.0 25.0 8.0 25.0

Related Pages

Tutorial:JavaScript Math