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()
ํจ์๋ ์ซ์์ ์ ๊ณฑ๊ทผ์ ๋ฐํํฉ๋๋ค.
๋ฌธ๋ฒ
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 |
๋ธ๋ผ์ฐ์ ํธํ์ฑ
Loadingโฆ