Home »
JavaScript
Math.cbrt() Method with Example in JavaScript
JavaScript | Math.cbrt() Method: Here, we are going to learn about the cbrt() method of Math class in JavaScript with Examples.
Submitted by Shivang Yadav, on December 26, 2019
JavaScript | Math.cbrt() Method
Math.cbrt() is a function in math library of JavaScript that is used to find the cube root of a number. The method will return the numeric value which is the cube root of the given number.
Syntax
Math.cbrt(val);
Parameters
- val – represents a value whose cube root to be found.
Return Value
The return type of this method is number, returns the cube root of the number.
Technical Insights
- JavaScript version: ECMAScript 6
- Browser support: Chrome v38, Internet Explorer v12, Mozilla v25, Safari v8, Opera mini v25.
Values accepted
Integer, floating-point, numeric string.
Invalid Values
Empty variable, empty array all will return NaN (Not a Number).
Example 1: Valid values for the method
console.log(Math.cbrt(8));
console.log(Math.cbrt(65.4));
console.log(Math.cbrt(-32.32));
console.log(Math.cbrt(0));
console.log(Math.cbrt("27.08"));
Output
2
4.0289565405335
-3.185349696715697
0
3.0029600413873867
Example 2: Invalid values for the method
console.log(Math.cbrt("Hello"));
// Output: NaN
console.log(Math.cbrt(1 + 5i));
// Output: Uncaught SyntaxError: Invalid or unexpected token
JavaScript Math Object Methods »