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

View in English Always switch to English

Math.sqrt()

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.sqrt() 함수는 숫자의 제곱근을 반환합니다.

x0,Math.sqrt(x)=x=the uniquey0such thaty2=x\forall x \geq 0, \mathtt{Math.sqrt(x)} = \sqrt{x} = \text{the unique} ; y \geq 0 ; \text{such that} ; y^2 = x

문법

js
Math.sqrt(x);

매개변수

x

숫자.

반환 값

주어진 숫자에 루트( )를 씌웁니다. 만약 숫자가 음수이면 NaN를 반환합니다.

설명

만약 x 가 음수라면 Math.sqrt() 함수는 NaN를 반환합니다.

sqrt()Math의 정적 메서드 이므로 만든 Math 객체의 메서드가 아니라 항상 Math.sqrt()함수를 사용해야합니다. (Math는 생성자가 없습니다.)

예제

Math.sqrt()

js
Math.sqrt(9); // 3
Math.sqrt(2); // 1.414213562373095

Math.sqrt(1); // 1
Math.sqrt(0); // 0
Math.sqrt(-1); // NaN

명세서

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

브라우저 호환성

참조