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.

Math.cbrt() 函数返回任意数字的立方根。

语法

Math.cbrt(x)

参数

x

任意数字。

返回值

给定数字的立方根

描述

该方法为 Math 的静态方法,因此请直接通过 Math.cbrt() 方式调用。

而不是作为你创建的 Math 对象的方法 (Math 不是构造函数)。

cbrt 是 "cube root" 的缩写,意思是立方根。

示例

使用 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.2599210498948732

规范

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

浏览器兼容性

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

参见