Strings in JS
They’re either UTF-16 or UCS-2 (now obselete). Depends on the interpreter. Each character takes up 1 or 2 bytes. UTF-16 is the only UTF that is not compatible with ASCII.
To decode a string from a typed array use:
|
|
# To learn
Can I safely use someString[i]
syntax? Some characters can take up 1 byte, and some 2. There’s String.prototype.codePointAt()
, I think it solves this problem.