C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript Math cbrt() methodThe JavaScript math cbrt() method returns the cube root of the given number. Unlike sqrt() method, this method accepts negative number. SyntaxThe cbrt() method is represented by the following syntax: Math.cbrt(num) Parameternum - A number. ReturnThe cube root of the given number. JavaScript Math cbrt() method exampleHere, we will understand cbrt() method through various examples. Example 1Let's see an example to print the cube root of the given number. <script> document.writeln(Math.cbrt(27)+"<br>"); document.writeln(Math.cbrt(-64)); </script> Output: 3 -4 Example 2Here, you can test cbrt() method with your own test cases. <script> function display() { var x=document.getElementById("num").value; document.getElementById("result").innerHTML=Math.cbrt(x); } </script> <form> Enter a number: <input type="text" id="num"> <input type="button" onclick="display()" value="submit"> </form> <p><span id="result"></span></p>
Next TopicJavaScript Math
|