Metóda JavaScript String fromCodePoint () vracia reťazec vytvorený pomocou danej postupnosti kódových bodov.
Syntax fromCodePoint()metódy je:
String.fromCodePoint(num1,… , numN)
fromCodePoint()Metóda je statické metódy, je nazývaný pomocou Stringnázov triedy.
parametre fromCodePoint ()
fromCodePoint()Metóda berie v:
- num1,…, numN - Postupnosť kódových bodov.
Vrátiť hodnotu z fromCodePoint ()
- Vráti reťazec vytvorený pomocou zadanej postupnosti kódových bodov.
Poznámky :
fromCodePoint()Metóda hodíRangeError, pokiaľ je uvedený neplatný kód Unicode bod.fromCodePoint()Metóda vracia reťazec, a nieStringobjekt.
Príklad: Použitie metódy fromCodePoint ()
let string1 = String.fromCodePoint(65, 66, 67); console.log(string1); // ABC let string2 = String.fromCharCode(72, 69, 76, 76, 79); console.log(string2); // HELLO // numbers can be passed as hexadecimals let string3 = String.fromCodePoint(0x2f804); console.log(string3); // "uD87EuDC04" // unlike fromCharCode() that requires surrogate pair to return supplementary char // fromCodePoint() can even return 4-byte supplementary chars let string4 = String.fromCodePoint(0x1f303); console.log(string4); // Unicode character "Night with Stars" let string5 = String.fromCodePoint(Infinity); console.log(string5); // RangeError
Výkon
ABC HELLO uD87E uDC04 RangeError: Neplatný bod kódu Infinity
Odporúčané čítanie: Reťazec JavaScript fromCharCode ()








