Skip to content
Related Articles

Related Articles

Improve Article

Math.cbrt() in JavaScript

  • Last Updated : 22 Jan, 2018

The 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 Used:
number:It is the number whose cuberoot you want to know.

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

Examples:



Input : Math.cbrt(8)
Output : 2
     
Input : Math.cbrt(-8)
Output : -2

Input : Math.cbrt(0)
Output : 0

Input : Math.cbrt(infinity)
Output : Infinity
  1. When a positive number is passed as a parameter.




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

    Output:

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




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

    Output:

    Output : -2
  3. When zero is passed as a parameter.




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

    Output:

    Output : 0
  4. When infinity is passed as a parameter.




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

    Output:

    Output : Infinity



My Personal Notes arrow_drop_up
Recommended Articles
Page :