Hacker News new | ask | show | jobs
by mhagemeister 1230 days ago
Author here.

That's great feedback! After reading your comment and re-reading the section in the article it does indeed sound wrong. Decided to remove that paragraph. Your explanation of the string representation is really good. Thanks for sharing!

1 comments

I'm glad it helped! Now that I'm actually looking at the different ways to manipulate strings in JavaScript and not going from memory, the traditional JavaScript "except when it doesn't" caveat applies.

It seems like _some_ string operations treat each surrogate (that's the fancy name for the half-characters) as its own character, while others (correctly) treat the surrogate pair as a single character.

This might explain how ensuring that the function name does not contain astral character would make it easier to use different string functions together without accidentally introducing bugs.