Getting roots of a number

suggest change

Square Root

Use Math.sqrt() to find the square root of a number. A negative argument returns NaN.

Math.sqrt(16) // 4

Cube Root

To find the cube root of a number, use Math.cbrt(). Unlike Math.sqrt, it accepts negative numbers.

Math.cbrt(27) // 3

Finding nth-roots

To find the nth root, use Math.pow() with a fractional exponent. The result is a floating-point approximation. This case happens to be exact.

Math.pow(64, 1/6) // 2

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents