Open In App

JavaScript Math cbrt() Function

Improve
Improve
Like Article
Like
Save
Share
Report

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.



Last Updated : 30 Dec, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads