The JavaScript exception “Invalid code point” occurs when NaN values, negative Integers (-1), non-Integers (5.4), or values larger than 0x10FFFF (1114111) are used with String.fromCodePoint().
Message:
RangeError: Invalid code point -1 (V8-based)
RangeError: -1 is not a valid code point (Firefox)
RangeError: Arguments contain a value that is out of range of code points (Safari)
What Went Wrong:
String.fromCodePoint() throws this error when passed NaN values, negative Integers (-1), non-Integers (5.4), or values larger than 0x10FFFF (1114111).
A code point is a value in the Unicode codespace; that is, the range of integers from 0 to 0x10FFFF.
Examples:
Invalid Cases:
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
Valid Cases:
String.fromCodePoint(42);
String.fromCodePoint(65, 90);
String.fromCodePoint(0x404);
String.fromCodePoint(0x2f804);
String.fromCodePoint(194564);
String.fromCodePoint(0x1d306, 0x61, 0x1d307);