RangeError: argument is not a valid code point

λ©”μ‹œμ§€

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"

μ°Έμ‘°