mozilla

Revision 316357 of Math.pow()

  • Revision slug: JavaScript/Reference/Global_Objects/Math/pow
  • Revision title: Math.pow
  • Revision id: 316357
  • Created:
  • Creator: ethertank
  • Is current revision? No
  • Comment

Revision Content

Summary

Returns base to the exponent power, that is, baseexponent.

Method of Math
Implemented in JavaScript 1.0
ECMAScript Edition ECMAScript 1st Edition

Syntax

Math.pow(base,exponent) 

Parameters

base
The base number.
exponents
The exponent to which to raise base.

Description

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

Examples

Example: Using Math.pow

function raisePower(x,y) {
   return Math.pow(x,y)
}

If x is 7 and y is 2, raisePower returns 49 (7 to the power of 2).

See also

Revision Source

<h2 id="Summary" name="Summary">Summary</h2>

<p>Returns <code>base</code> to the <code>exponent</code> power, that is, <code>base<sup>exponent</sup></code>.</p>

<table class="standard-table">
  <thead>
    <tr>
      <th class="header" colspan="2">Method of <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Math"><code>Math</code></a></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Implemented in</td>
      <td>JavaScript 1.0</td>
    </tr>
    <tr>
      <td>ECMAScript Edition</td>
      <td>ECMAScript 1st Edition</td>
    </tr>
  </tbody>
</table>

<h2 id="Syntax" name="Syntax">Syntax</h2>

<pre class="syntaxbox"><code>Math.pow(<em>base</em>,<em>exponent</em>) </code></pre>


<h3 id="Parameters" name="Parameters">Parameters</h3>
<dl>
  <dt><code>base</code></dt>
  <dd>The base number.</dd>
  <dt><code>exponents</code></dt>
  <dd>The exponent to which to raise <code>base</code>.</dd>
</dl>


<h2 id="Description" name="Description">Description</h2>

<p>Because <code>pow</code> is a static method of <code>Math</code>, you always use it as <code>Math.pow()</code>, rather than as a method of a <code>Math</code> object you created.</p>

<h2 id="Examples" name="Examples">Examples</h2>

<h3 id="Example:_Using_Math.pow" name="Example:_Using_Math.pow">Example: Using <code>Math.pow</code></h3>

<pre class="brush:js">function raisePower(x,y) {
   return Math.pow(x,y)
}</pre>

<p>If <code>x</code> is 7 and <code>y</code> is 2, raisePower returns 49 (7 to the power of 2).</p>

<h2 id="See_also" name="See_also">See also</h2>

<ul>
<li><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Math/exp" title="JavaScript/Reference/Global_Objects/Math/exp">Math.exp</a></li>
<li><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Math/log" title="JavaScript/Reference/Global_Objects/Math/log">Math.log</a></p></li>
</li>


<!-- languages({
	"fr": "fr/R\u00e9f\u00e9rence_de_JavaScript_1.5_Core/Objets_globaux/Math/pow"
}) -->
Revert to this revision