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 July 2015.

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® 2025 Language Specification
# sec-math.sqrt

브라우저 호환성

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
sqrt

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

참조