メッセージ
RangeError: {0} is not a valid code point (Firefox)
RangeError: Invalid code point {0} (Chrome)
エラータイプ
何がうまくいかなかったのか?
String.fromCodePoint() メソッドは、有効なコードポイントのみを受け付けます。
コードポイントは、ユニコード文字集合の値です。これは整数 0 から 0x10FFFF までの範囲です。
NaN や、-1 などの負数(negative Integers)、3.14 などの非整数値(non-integers)、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"