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

isFinite()

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์›”โฉ.

isFinite() ์ „์—ญ ํ•จ์ˆ˜๋Š” ์ฃผ์–ด์ง„ ๊ฐ’์ด ์œ ํ•œ์ˆ˜์ธ์ง€ ํŒ๋ณ„ํ•ฉ๋‹ˆ๋‹ค. ํ•„์š”ํ•œ ๊ฒฝ์šฐ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ๋จผ์ € ์ˆซ์ž๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

์‹œ๋„ํ•ด ๋ณด๊ธฐ

function div(x) {
  if (isFinite(1000 / x)) {
    return "Number is NOT Infinity.";
  }
  return "Number is Infinity!";
}

console.log(div(0));
// Expected output: "Number is Infinity!""

console.log(div(1));
// Expected output: "Number is NOT Infinity."

๊ตฌ๋ฌธ

js
isFinite(testValue);

๋งค๊ฐœ๋ณ€์ˆ˜

testValue

์œ ํ•œํ•œ์ง€ ํŒ๋ณ„ํ•  ๊ฐ’.

๋ฐ˜ํ™˜ ๊ฐ’

testValue๊ฐ€ ์–‘ ๋˜๋Š” ์Œ์˜ Infinity, NaN, ๋˜๋Š” undefined๋ฉด false, ์•„๋‹ˆ๋ฉด true.

์„ค๋ช…

isFinite()์€ ์ตœ์ƒ์œ„ ํ•จ์ˆ˜๋กœ ์–ด๋–ค ๊ฐ์ฒด์™€๋„ ์—ฐ๊ฒฐ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.

์ˆซ์ž๊ฐ€ ์œ ํ•œ์ˆ˜์ธ์ง€ ํŒ๋ณ„ํ•˜๊ธฐ ์œ„ํ•ด isFinite()์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. isFinite()์€ ์ฃผ์–ด์ง„ ์ˆ˜๋ฅผ ๊ฒ€์‚ฌํ•ด ๊ทธ ๊ฐ’์ด NaN, ์–‘์˜ ๋ฌดํ•œ๋Œ€, ๋˜๋Š” ์Œ์˜ ๋ฌดํ•œ๋Œ€์ด๋ฉด false๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด true๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

์˜ˆ์ œ

isFinite() ์‚ฌ์šฉํ•˜๊ธฐ

js
isFinite(Infinity); // false
isFinite(NaN); // false
isFinite(-Infinity); // false

isFinite(0); // true
isFinite(2e64); // true
isFinite(910); // true

isFinite(null); // true, would've been false with the
// more robust Number.isFinite(null)

isFinite("0"); // true, would've been false with the
// more robust Number.isFinite("0")

๋ช…์„ธ์„œ

Specification
ECMAScriptยฎ 2026 Languageย Specification
# sec-isfinite-number

๋ธŒ๋ผ์šฐ์ € ํ˜ธํ™˜์„ฑ

๊ฐ™์ด ๋ณด๊ธฐ