We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

这篇翻译不完整。请帮忙从英语翻译这篇文章

概述

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

语法

Math.cbrt(x)

参数

x
任意数字.

描述

参数 x 会被自动类型转换成 number 类型.

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

示例

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

为了让所有地方都可以使用, 可参照下方函数:

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

规范

Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
Math.cbrt
Standard Initial definition.

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 未实现 25 (25) 未实现 未实现 未实现
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 未实现 未实现 25.0 (25) 未实现 未实现 未实现

 

文档标签和贡献者

此页面的贡献者: SphinxKnight, wangyukai04, teoli, ziyunfei
最后编辑者: SphinxKnight,