We're looking for a person or people to help audit MDN to find places we could speed up. Is this you or someone you know? Check out the RFP: https://mzl.la/2IHcMiE

我們的志工尚未將本文翻譯為 正體中文 (繁體) 版本。加入我們,幫忙翻譯!
您也可以閱讀本文的 English (US) 版本。


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

Error type


What went wrong?

The String.fromCodePoint() method accepts valid code points only.

A code point is a value in the Unicode codespace; that is, the range of integers from 0 to 0x10FFFF.

Using NaN values, negative Integers (-1), non-Integers (3.14), or values larger than 0x10FFFF (1114111) won't work with this method.


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);   // "AZ"
String.fromCodePoint(0x404);    // "\u0404"
String.fromCodePoint(0x2F804);  // "\uD87E\uDC04"
String.fromCodePoint(194564);   // "\uD87E\uDC04"
String.fromCodePoint(0x1D306, 0x61, 0x1D307) // "\uD834\uDF06a\uD834\uDF07"

See also


 此頁面的貢獻者: fscholz
 最近更新: fscholz,