Name

Math.pow() — compute x y

Synopsis

Math.pow(x, y)

Arguments

x

The number to be raised to a power.

y

The power that x is to be raised to.

Returns

x to the power of y, x y

Description

Math.pow() computes x to the power of y. Any values of x and y may be passed to Math.pow(). However, if the result is an imaginary or complex number, Math.pow() returns NaN. In practice, this means that if x is negative, y should be a positive or negative integer. Also, bear in mind that large exponents can easily cause floating-point overflow and return a value of Infinity.

Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.