Movatterモバイル変換


[0]ホーム

URL:


  1. 개발자를 위한 웹 기술
  2. JavaScript
  3. JavaScript 참고서
  4. 표준 내장 객체
  5. Math
  6. Math.cbrt()

This page was translated from English by the community.Learn more and join the MDN Web Docs community.

View in EnglishAlways switch to English

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 ⁨2015년 7월⁩.

Math.cbrt() 함수는 주어진 수의 세제곱근을 반환합니다. 즉,

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

구문

js
Math.cbrt(x);

매개변수

x

숫자.

반환 값

주어진 수의 세제곱근.

설명

cbrt()Math의 정적 메서드이므로, 사용자가 생성한Math 객체의 메서드로 호출할 수 없고 항상Math.cbrt()를 사용해야 합니다. (Math는 생성자가 아닙니다)

예제

Math.cbrt() 사용하기

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

폴리필

모든x0x \geq 0에서x3=x1/3\sqrt[3]{x} = x^{1/3} 이므로,Math.cbrt()는 다음 함수로 폴리필할 수 있습니다.

js
if (!Math.cbrt) {  Math.cbrt = (function (pow) {    return function cbrt() {      // ensure negative numbers remain negative:      return x < 0 ? -pow(-x, 1 / 3) : pow(x, 1 / 3);    };  })(Math.pow); // localize Math.pow to increase efficiency}

명세

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

브라우저 호환성

같이 보기

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp