Math.cbrt()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

A função Math.cbrt() retorna a raiz cúbica de um número, isto é

Math.cbrt(x)=x3 = y, tal quey3=x\mathtt{Math.cbrt(x)} = \sqrt[3]{x} = \text{the unique} ; y ; \text{such that} ; y^3 = x

Sintaxe

Math.cbrt(x)

Parâmetros

x

Um número.

Valor de retorno

A raiz cúbica do número fornecido.

Descrição

Porque cbrt() é um método estático de Math, você sempre irá utilizar como Math.cbrt(), ao invés de um método de um objeto Math que você tenha criado (Math não é um construtor).

Exemplos

Utilizando Math.cbrt()

js
Math.cbrt(NaN); // NaN
Math.cbrt(-1); // -1
Math.cbrt(-0); // -0
Math.cbrt(-Infinity); // -Infinity
Math.cbrt(0); // 0
Math.cbrt(1); // 1
Math.cbrt(Infinity); // Infinity
Math.cbrt(null); // 0
Math.cbrt(2); // 1.2599210498948734

Polyfill

Para todo x0x \geq 0, temos x3=x1/3\sqrt[3]{x} = x^{1/3}, então isto pode ser simulado pela seguinte função:

js
if (!Math.cbrt) {
  Math.cbrt = function (x) {
    var y = Math.pow(Math.abs(x), 1 / 3);
    return x < 0 ? -y : y;
  };
}

Especificações

Specification
ECMAScript® 2025 Language Specification
# sec-math.cbrt

Compatibilidade com navegadores

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
cbrt

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

Veja também