JavaScript Math.cbrt()
Syntax & Examples


Math.cbrt() static-method

The Math.cbrt() method in JavaScript returns the cube root of a number. It is a static method of Math, meaning it is always used as Math.cbrt() and not as a method of a Math object created (Math is not a constructor).


Syntax of Math.cbrt()

The syntax of Math.cbrt() static-method is:

Math.cbrt(x)

This cbrt() static-method of Math returns the cube root of x.

Parameters

ParameterOptional/RequiredDescription
xrequiredA number for which to return the cube root.

Return Type

Math.cbrt() returns value of type Number.



✐ Examples

1 Using Math.cbrt() with a positive number

In this example, we use the Math.cbrt() method to find the cube root of 27.

For example,

  1. We call Math.cbrt() with 27 as the argument.
  2. The method returns the cube root of 27.
  3. We log the result to the console using console.log().

JavaScript Program

console.log(Math.cbrt(27));

Output

3

2 Using Math.cbrt() with a negative number

In this example, we use the Math.cbrt() method to find the cube root of -8.

For example,

  1. We call Math.cbrt() with -8 as the argument.
  2. The method returns the cube root of -8.
  3. We log the result to the console using console.log().

JavaScript Program

console.log(Math.cbrt(-8));

Output

-2

3 Using Math.cbrt() with a fractional number

In this example, we use the Math.cbrt() method to find the cube root of 0.125.

For example,

  1. We call Math.cbrt() with 0.125 as the argument.
  2. The method returns the cube root of 0.125.
  3. We log the result to the console using console.log().

JavaScript Program

console.log(Math.cbrt(0.125));

Output

0.5

Summary

In this JavaScript tutorial, we learned about cbrt() static-method of Math: the syntax and few working examples with output and detailed explanation for each example.