JavaScript Math.cbrt() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Math

Definition

Math.cbrt(x) returns the cube root of a number. That is the number which, multiplied by itself three times, gives x. For example, the cube root of 27 is 3.

Math is built into JavaScript. Call the method directly. It is not a constructor, so never write new Math().

Syntax

Call Math.cbrt() like this. Start with this line.

JavaScript
Math.cbrt(x)
CallWhat it does
Math.cbrt(x)Returns the cube root of x.

Built into JavaScript. Call Math.cbrt() on the Math object — no import required.

Library declarations
JavaScript
Math.cbrt(x)
JavaScript
interface Math {
  cbrt(x: number): number;
}

Parameters

ParameterDescription
xRequired. A number. Other values are converted to a number first.

Return Value

Return ValueDescription
numberThe cube root of x. Returns NaN if x cannot be turned into a number.

JavaScript Examples

Example 1 — Basic Use

Perfect cubes give whole numbers. Other numbers give decimals.

JavaScript
console.log(Math.cbrt(27));    // 3
console.log(Math.cbrt(1000));  // 10
console.log(Math.cbrt(2));     // 1.2599210498948732
console.log(Math.cbrt(0));     // 0
Try It Yourself

How It Works

  1. Perfect cube. 3 * 3 * 3 is 27, so the cube root is 3.
  2. Another cube. 10 * 10 * 10 is 1000, so you get 10.
  3. Not a cube. 2 is not a perfect cube, so you get a decimal.

Example 2 — Negative Numbers

Math.cbrt() works for negative numbers. Math.pow(x, 1/3) does not.

JavaScript
console.log(Math.cbrt(-8));        // -2
console.log(Math.pow(-8, 1 / 3));  // NaN
console.log(Math.cbrt(-27));       // -3
Try It Yourself

How It Works

  1. Negative cube root. -2 * -2 * -2 is -8, so the cube root of -8 is -2.
  2. pow fails. Math.pow(-8, 1 / 3) returns NaN.
  3. Use cbrt. Choose Math.cbrt() when the number can be negative.

Example 3 — Side of a Cube From Its Volume

The volume of a cube is side * side * side. Use Math.cbrt() to go backwards.

JavaScript
function sideFromVolume(volume) {
  return Math.cbrt(volume);
}

console.log(sideFromVolume(125));   // 5
console.log(sideFromVolume(64));    // 4
console.log(sideFromVolume(10).toFixed(2));  // 2.15
Try It Yourself

How It Works

  1. Volume in. A cube with volume 125 has sides of length 5.
  2. Another cube. Volume 64 means side 4.
  3. Not exact. For 10, round the answer with toFixed(2).

Browser & Runtime Support

Math.cbrt() is part of ES2015 and is Baseline Widely available in modern browsers and Node.js.

✓ Baseline · ES2015

Math.cbrt()

Supported in Chrome, Firefox, Safari, Edge, and Node.js for years. Safe for modern apps without a polyfill.

98% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Math.cbrt Excellent

Bottom line: Use Math.cbrt() in new code. Only very old browsers, like Internet Explorer, lack it.

Frequently Asked Questions

Math.cbrt(x) returns the cube root of x. Math.cbrt(27) is 3 and Math.cbrt(1000) is 10.
Yes. Math.cbrt(-8) is -2. A cube root of a negative number is negative.
Math.pow(-8, 1/3) returns NaN, and results can be slightly off. Math.cbrt() is simpler and more exact.
sqrt finds the square root (multiply twice) and fails for negatives. cbrt finds the cube root (multiply three times) and works for negatives.
It was added in ES2015 and works in all modern browsers and Node.js.

Next: ceil()

Learn how to round a number up to a whole number.

ceil() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful