๋ฉ์์ง
RangeError: {0} is not a valid code point (Firefox) RangeError: Invalid code point {0} (Chrome)
์๋ฌ ํ์
๋ฌด์์ด ์๋ชป๋์์๊น?
String.fromCodePoint()
๋ฉ์๋๋ ์ ํจํ ์ฝ๋ ํฌ์ธํธ(code point)๋ง์ ๋ฐ์๋ค์
๋๋ค.
code point๋ ์ ๋์ฝ๋์ ์ฝ๋ ์คํ์ด์ค ๊ฐ์ผ๋ก, 0
๋ถํฐ 0x10FFFF
๊น์ง์ ์ ์ ๋ฒ์์
๋๋ค.
NaN
์ ์ฌ์ฉํ๋ ๊ฐ, ์์ (-1
), ์ ์๊ฐ ์๋ ์(3.14), ๋๋ 0x10FFFF
(1114111
) ๋ณด๋ค ํฐ ๊ฐ์ ์ด ํจ์์ ์ ์ฉ๋ ์ ์์ต๋๋ค.
์
์ ํจํ์ง ์์ ๊ฒฝ์ฐ
String.fromCodePoint('_'); // RangeError
String.fromCodePoint(Infinity); // RangeError
String.fromCodePoint(-1); // RangeError
String.fromCodePoint(3.14); // RangeError
String.fromCodePoint(3e-2); // RangeError
String.fromCodePoint(NaN); // RangeError
์ ํจํ ๊ฒฝ์ฐ
String.fromCodePoint(42); // "*"
String.fromCodePoint(65, 90); // "AZ"
String.fromCodePoint(0x404); // "\u0404"
String.fromCodePoint(0x2F804); // "\uD87E\uDC04"
String.fromCodePoint(194564); // "\uD87E\uDC04"
String.fromCodePoint(0x1D306, 0x61, 0x1D307) // "\uD834\uDF06a\uD834\uDF07"