๐ง under construction
Last updated 2 years ago
Was this helpful?
JS โฉ value โฉ primitive โฉ String โฉ Unicode โฉ encoding โฉ UTF-16 โฉ code unit
UTF-16 code units are 16-bit unsigned integers. (0x0000 ~ 0xFFFF)
string.codePointAt(index)
string.slice(start, end)
string[index]
uses index of code units, not charactersโ
.split("") will split by UTF-16 code units and will separate surrogate pairsโ
split("")
By default, regular expressions work on code units, not actual charactersโ
(dangerous) use code units
string.length
string.charCodeAt(index)
(safe) use code points
string iteration (for-of loop)
replit โฉ code unit
// code
Unicode
Eloquent JavaScript โฉ Strings & Character Codes
UTF-16 characters, code points, grapheme clusters
String.prototype โฉ
.charCodeAt()
.codePointAt()
String โฉ
.fromCodePoint()
.fromCharCode()