What is Math.cbrt() in JavaScript?

Math is a built-in object in JavaScript that contains different methods and properties used to perform mathematical operations. It contains a cbrt() function, which is used to compute the cube root of a specified number.

Syntax

Math.cbrt(param);

Parameter

  • param: This is the input value of the Number type for which we want to find the cbrt().

Number in JavaScript is a 64-bit double-precision value that is the same as double in C# or Java.

Return value

  • Number: It returns the cube root of the input parameter param. It is of the Number type.

  • Infinity: The function returns this if the input parameter param is Infinity.

  • NaN: The function returns this if the input parameter param is NaN.

Example

console.log("cbrt(-8) = " + Math.cbrt(-8));
console.log("cbrt(-1) = " + Math.cbrt(-1));
console.log("cbrt(64) = " + Math.cbrt(64));
console.log("cbrt(∞) = " + Math.cbrt(Infinity));
console.log("cbrt(null) = " + Math.cbrt(null));
console.log("cbrt(NaN) = " + Math.cbrt(NaN));

Free Resources