Number.NaN
Number.NaN
์์ฑ์ Not-A-Number(์ซ์๊ฐ ์๋)๋ฅผ ๋ํ๋ธ๋ค. NaN
๊ณผ ๊ฐ๋ค.
function clean(x) {
if (x === Number.NaN) return null; // can never be true
if (isNaN(x)) return 0;
}
clean(Number.NaN); // 0
์ ์ ์์ฑ์ด๋ฏ๋ก ์ ๊ทผํ๊ธฐ ์ํด Number
๊ฐ์ฒด๋ฅผ ์์ฑํ ํ์๋ ์๋ค.
์๋๋ฉด!! NaN === NaN
์ ๋ true ๊ฐ ๋์ค์ง ์๋๋ค. ๊ทธ๋์ can never be true
์ด๋ค.
Last updated
Was this helpful?