Latest web development tutorials

JavaScript pow () method

Math Object Reference JavaScript Math Object

Examples

4 returns to the third power (4 * 4 * 4):

Math.pow(4,3);

Output:

64

try it"

Definition and Usage

pow () method returns the x power of y.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support pow () method


grammar

Math.pow( x , y )

Parameter Value

参数 描述
x 必需。底数。必须是数字。
y 必需。幂数。必须是数字。

return value

类型 描述
Number x 的 y 次幂。

technical details

JavaScript version: 1.0


More examples

Examples

In the following example, we'll pow () to use a different combination of numbers:

var a=Math.pow(0,1);
var b=Math.pow(1,1);
var c=Math.pow(1,10);
var d=Math.pow(3,3);
var e=Math.pow(-3,3);
var f=Math.pow(2,4);

a, b, c, d, e, and f output:

0
1
1
27
-27
16

try it"


Math Object Reference JavaScript Math Object