Math.expm1()

  • Revision slug: Web/JavaScript/Reference/Global_Objects/Math/expm1
  • Revision title: Math.expm1()
  • Revision id: 482403
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment New ECMAScript 6 math function (doc bug 717379)

Revision Content

{{JSRef("Global_Objects", "Math")}} {{harmony}}

Summary

The Math.expm1() function returns Ex - 1, where x is the argument, and E is Euler's constant, the base of the natural logarithms.

Syntax

Math.expm1(x)

Parameters

x
A number.

Description

Because expm1 is a static method of Math, you always use it as Math.expm1(), rather than as a method of a Math object you created (Math is not a constructor).

Examples

Example: Using Math.expm1

The following function returns the exponential value of the variable x:

function getExpm1(x) {
   return Math.expm1(x)
}

If you pass getExpm1 the value 1, it returns 1.718281828459045.

Specifications

Specification Status Comment
{{SpecName('ES6', '#sec-math.expm1', 'Math.expm1')}} {{Spec2('ES6')}} Initial definition.

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatNo}} {{CompatGeckoDesktop("25")}} {{CompatNo}} {{CompatNo}} {{CompatNo}}
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{CompatNo}} {{CompatGeckoMobile("25")}} {{CompatNo}} {{CompatNo}} {{CompatNo}}

See also

  • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.

Revision Source

<div>
  {{JSRef("Global_Objects", "Math")}} {{harmony}}</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <code><strong>Math.expm1()</strong></code> function returns <code>E<sup>x</sup></code> - 1, where <code>x</code> is the argument, and <code>E</code> is Euler's constant, the base of the natural logarithms.</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">
<code>Math.expm1(<em>x</em>)</code></pre>
<h3 id="Parameters" name="Parameters">Parameters</h3>
<dl>
  <dt>
    <code>x</code></dt>
  <dd>
    A number.</dd>
</dl>
<h2 id="Description" name="Description">Description</h2>
<p>Because <code>expm1</code> is a static method of <code>Math</code>, you always use it as <code>Math.expm1()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p>
<h2 id="Examples" name="Examples">Examples</h2>
<h3 id="Example:_Using_Math.exp" name="Example:_Using_Math.exp">Example: Using <code>Math.expm1</code></h3>
<p>The following function returns the exponential value of the variable <code>x</code>:</p>
<pre class="brush:js">
function getExpm1(x) {
   return Math.expm1(x)
}</pre>
<p>If you pass <code>getExpm1</code> the value 1, it returns 1.718281828459045.</p>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
  <tbody>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
    <tr>
      <td>{{SpecName('ES6', '#sec-math.expm1', 'Math.expm1')}}</td>
      <td>{{Spec2('ES6')}}</td>
      <td>Initial definition.</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<div>
  {{CompatibilityTable}}</div>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari (WebKit)</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatGeckoDesktop("25")}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Phone</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatGeckoMobile("25")}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
  <li>The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.</li>
</ul>
Revert to this revision