JavaScript pow() method
- Previous Page PI
- Next Page random()
- Go to the Previous Level JavaScript Math Reference Manual
Definition and usage
pow()
This method can return x of y Power (xyThe value of ).
Note
If the result is a complex number or negative, this method will return NaN. If a floating-point overflow occurs due to an excessively large exponent, this method will return Infinity.
Instance
Example 1
Returns the value of 4 raised to the power of 3 (4*4*4):
Math.pow(4, 3);
Example 2
Use the pow() method for different 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);
Syntax
Math.pow(x, y)
Parameter value
Parameter | Description |
---|---|
x | Required. The base. It must be a number. |
y | Required. The exponent. It must be a number. |
Technical details
Return value: | Value, representing x of y The value of the power (xy). |
---|---|
JavaScript Version: | ECMAScript 1 |
Browser Support
Method | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
pow() | Support | Support | Support | Support | Support |
Related Pages
Tutorial:JavaScript Math
- Previous Page PI
- Next Page random()
- Go to the Previous Level JavaScript Math Reference Manual