--- title: 'RangeError: argument is not a valid code point' slug: Web/JavaScript/Reference/Errors/Not_a_codepoint tags: - Error - Errors - JavaScript - RangeError translation_of: Web/JavaScript/Reference/Errors/Not_a_codepoint ---
JavaScript の例外 "Invalid code point" は、 {{jsxref("NaN")}} 値、負の整数 (-1)、 整数以外 (5.4)、 0x10FFFF より大きい数 (1114111) が {{jsxref("String.fromCodePoint()")}} で使用された場合に発生します。
RangeError: {0} is not a valid code point (Firefox) RangeError: Invalid code point {0} (Chromium)
{{jsxref("RangeError")}}
{{jsxref("String.fromCodePoint()")}} は、 {{jsxref("NaN")}} 値、負の整数 (-1)、 整数以外 (5.4)、 0x10FFFF より大きい数 (1114111) が渡されるとこのエラーを発生します。
コードポイントは、 Unicode 文字集合の値です。これは整数 0
から 0x10FFFF
までの範囲です。
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"