• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • Math.expm1()

    Math.expm1()函数返回Ex - 1,其中x是该函数的参数,E是自然对数的底数2.718281828459045.

    语法

    Math.expm1(x)
    

    参数

    x
    任意数字.

    描述

    参数x会被自动类型转换成number 类型.

    expm1 是"exponent minus 1"的缩写.

    示例

    Math.expm1(1)     // 1.7182818284590453
    Math.expm1(-38)   // -1
    Math.expm1("-38") // -1
    Math.expm1("foo") // NaN
    

    Polyfill

    因为我们已经有了Math.exp 函数,所以很容易 polyfill.

    Math.expm1 = Math.expm1 || function (x) {
        return Math.exp(x) - 1
    }
    

    上篇:Math.exp()

    下篇:Math.clz32()