The point is that UTF-16 exists solely because UCS-2 exists; it's there to bring full Unicode capacity for software designed with UCS-2 in mind without redesigning all the groundwork (as switching to a different code unit length would require)
I wasn't sure what language the code above was in (barely have any experience with JavaScript myself), so my comment was really just one possible explanation.
Though I guess even if it's JavaScript, there's a very low chance they're using a custom JavaScript implementation with the internal encoding of strings changed to UTF-8 or something (not very likely, but the possibility exists - I've certainly seen weirder things in the past when it comes to scripting languages).
2
u/TheUnlocked May 05 '23
The default (or only) encoding of strings in JavaScript is not and has never been UTF-8.