JS Built-ins
← Math115 / 215
Mathexpm1beginner

Math.expm1() Always Returns a Number

πŸ“– Usage Example
// e^x minus 1, precise for very small x
Math.expm1(0)     // β†’ 0
Math.expm1(0.001) // β†’ 0.0010005...

Use Math.expm1(x) instead of Math.exp(x) - 1 for small x values to avoid floating-point precision loss.

Math.expm1(x)

Math.expm1() always returns a value of type number for any input.

Challenge: Verify the return type of Math.expm1() for various inputs.

πŸ’‘ Hints (2)
  • β€’ All Math methods return a number primitive
  • β€’ expm1 is especially useful for tiny values of x near 0