Skip to content

JavaScript cube root | Math cbrt()

  • by

Use Math cbrt() method to get the cube root of a number in JavaScript. This function returns the cube root of a number, that is

M a t h . c b r t ( x ) = x 3 = the unique y such that y 3 = x

JavaScript cube root

Simple example code.

<!DOCTYPE html>
<html>
<body>
  <script>
   console.log(Math.cbrt(-1));

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

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

   console.log(Math.cbrt(64));
 </script>
</body>
</html>

Output:

JavaScript cube root Math cbrt

More example

Math.cbrt(NaN); // NaN
Math.cbrt(-1); // -1
Math.cbrt(-0); // -0
Math.cbrt(-Infinity); // -Infinity
Math.cbrt(0); // 0
Math.cbrt(1); // 1
Math.cbrt(Infinity); // Infinity
Math.cbrt(null); // 0
Math.cbrt(2);  // 1.2599210498948732

Do comment if you have any doubts or suggestion on this JS math function topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *