--- title: Math.cbrt() slug: Web/JavaScript/Reference/Global_Objects/Math/cbrt tags: - JavaScript - Math - Method - Reference translation_of: Web/JavaScript/Reference/Global_Objects/Math/cbrt ---
Math.cbrt() 関数は、引数として与えた数の立方根を返します。すなわち、
Math.cbrt(x)
与えられた数値の立方根です。
cbrt() は Math の静的なメソッドであるため、自ら生成した Math オブジェクトのメソッドとしてではなく、常に、 Math.cbrt() として使用してください (Math はコンストラクターではありません)。
すべての に対して、 が存在し、次の関数でエミュレートできます:
if (!Math.cbrt) {
Math.cbrt = (function(pow) {
return function cbrt(x){
// ensure negative numbers remain negative:
return x < 0 ? -pow(-x, 1/3) : pow(x, 1/3);
};
})(Math.pow); // localize Math.pow to increase efficiency
}
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
| 仕様書 |
|---|
| {{SpecName('ESDraft', '#sec-math.cbrt', 'Math.cbrt')}} |
{{Compat("javascript.builtins.Math.cbrt")}}