JavaScript Math cbrt()

The JavaScript Math.cbrt() function returns the cube root of a specified number.

The syntax of the Math.cbrt() function is:

Math.cbrt(x)

cbrt(), being a static method, is called using the Math class name.


Math.cbrt() Parameters

The Math.cbrt() function takes in:

  • x - A number

Return value from Math.cbrt()

  • Returns the cube root of a given number.
  • Returns NaN if the argument is non-numeric.

Example: Using Math.cbrt()

var value = Math.cbrt(216);
console.log(value); // 6

var value = Math.cbrt(-1);
console.log(value); // -1

var value = Math.cbrt(-2);
console.log(value); // -1.2599210498948732

var value = Math.cbrt(-Infinity);
console.log(value); // -Infinity

var value = Math.cbrt(null);
console.log(value); // 0

Output

6
-1
-1.2599210498948732
-Infinity
0

Recommended readings: