JavaScript cbrt

The JavaScript cbrt function is one of the Math functions, and it is used to find the cube root of a specified expression or an individual number. The basic syntax of the JavaScript cbrt Function is:


Number: It can be a number or a valid numerical expression.

  • If the number argument is a positive or negative number, the JavaScript cbrt function will return the cube root of a given value.
  • If the number argument is not a number, it will return NaN.
  • When the number argument is Null, it will return Zero.

JavaScript cbrt Function Example

The cbrt function is used to find the cube root of a given number. In this example, We are going to find the cube root of different data types and display the output

  1. First two statements, We used the JavaScript cbrt Function directly on both the Positive integer and negative integer. From the below screenshot, you can observe that it is returning the cube roots.
  2. Next two statements, We used the JavaScript method on both the Positive and negative Decimal values this Function is working fine with decimal values as well.
  3. Next statement, We tried the Math method on the String value. As we said before, this will return NaN (Not a Number) as output.
  4. Last, We tried the cbrt() Function on a Null value, and it returned Zero as output.
<!DOCTYPE html>
    <title> JavaScriptCBRTFunction </title>
  <h1> JavaScriptCBRTFunction </h1>
  <p id = "Pos"></p>
  <p id = "Neg"></p>
  <p id = "Dec"></p>
  <p id = "Neg_Dec"></p>
  <p id = "Str"></p>
  <p id = "Null"></p>
    document.getElementById("Pos").innerHTML = Math.cbrt(10);
    document.getElementById("Neg").innerHTML = Math.cbrt(-10);
    document.getElementById("Dec").innerHTML = Math.cbrt(14.05);
    document.getElementById("Neg_Dec").innerHTML = Math.cbrt(-6.05);
    document.getElementById("Str").innerHTML = Math.cbrt("JavaScript");
    document.getElementById("Null").innerHTML = Math.cbrt(null);
JavaScript CBRT Function

Comments are closed.