Home » JavaScript Tutorial

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);

Parameter(s):

  • 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





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.