--- title: Math.sqrt() slug: Web/JavaScript/Reference/Global_Objects/Math/sqrt translation_of: Web/JavaScript/Reference/Global_Objects/Math/sqrt ---
{{JSRef}}

 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

문법

Math.sqrt(x)

매개변수

x
숫자.

반환 값

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

설명

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

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

예제

 Math.sqrt()

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

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

표준

표준 상태 비고
{{SpecName('ES1')}} {{Spec2('ES1')}} Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.17', 'Math.sqrt')}} {{Spec2('ES5.1')}}  
{{SpecName('ES6', '#sec-math.sqrt', 'Math.sqrt')}} {{Spec2('ES6')}}  
{{SpecName('ESDraft', '#sec-math.sqrt', 'Math.sqrt')}} {{Spec2('ESDraft')}}  

브라우저 호환성

{{Compat("javascript.builtins.Math.sqrt")}}

참조