Skip to content
Related Articles
Open in App
Not now

Related Articles

JavaScript Math cbrt() Function

Improve Article
Save Article
  • Last Updated : 30 Dec, 2022
Improve Article
Save Article

The Javascript Math.cbrt() function is used to find the cube root of a number. The cube root of a number is denoted as Math.cbrt(x)=y such that y^3=x. 

Syntax:

Math.cbrt(number)

Parameters: This function accepts a single parameter.

  • number: The number whose cube root you want to know. 

Return Value: It returns the cube root of the given number.

The below example will give you an idea of cbrt() function:

Example 1: When a positive number is passed as a parameter. 

Javascript




<script type="text/javascript">
    console.log("Output : " + Math.cbrt(8));        
</script>


Output:

Output : 2

Example 2: When a negative number is passed as a parameter. 

Javascript




<script type="text/javascript">
    console.log("Output : " + Math.cbrt(-8));        
</script>


Output:

Output : -2

Example 3: When zero is passed as a parameter. 

Javascript




<script type="text/javascript">
    console.log("Output : " + Math.cbrt(0));        
</script>


Output:

Output : 0

Example 4: When infinity is passed as a parameter. 

Javascript




<script type="text/javascript">
    console.log("Output : " + Math.cbrt(infinity));        
</script>


Output:

Output : Infinity

We have a complete list of Javascript Math Objects methods, to check those please go through this Javascript Math Object Complete reference article.


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!