RangeError: argument is not a valid code point

๋ฉ”์‹œ์ง€

RangeError: {0} is not a valid code point (Firefox)
RangeError: Invalid code point {0} (Chrome)

์—๋Ÿฌ ํ˜•์‹

RangeError

๋ฌด์—‡์ด ์ž˜๋ชป๋˜์—ˆ์„๊นŒ?

String.fromCodePoint() (en-US) ๋ฉ”์†Œ๋“œ๋Š” ์œ ํšจํ•œ ์ฝ”๋“œ ํฌ์ธํŠธ(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"

์ฐธ์กฐ