Math.cbrt()

Returns the cube root of a number.

Since ES2015 Spec ↗

Syntax

Math.cbrt(x)

Parameters

NameTypeRequiredDescription
x number Yes The number whose cube root is returned.

Returns

number — The cube root of x.

Examples

console.log(Math.cbrt(27));
Output
3
console.log(Math.cbrt(-8));
Output
-2

Notes

Unlike `sqrt`, this works for negative numbers (cube root of -8 is -2). More accurate than `Math.pow(x, 1/3)` for negatives.

Browser & runtime support

EnvironmentSince version
chrome 38
firefox 25
safari 8
edge 12
node 0.12

See also