Earlier quoted context omitted.
I think you misunderstand -- I'm referring to the actual systems-level implementation of the browser engine itself. I'm not talking about the implementation of web apps. Consider a pattern like this: A page calls document.createElement(), adds a large text node (say, the collected works of Shakespeare in text form) to it, calls window.getComputedStyle() on that element, then throws the element away. This series of DO…
What part of that process requires UTF-16? JavaScript doesn't require UTF-16; it just requires Unicode. You could use UTF-8 in your JavaScript implementation as well.
''.length == 2 ''[0] == first codepoint in the surrogate pair ''[1] == second codepoint in the surrogate pair
Any JS implementation using UTF-8 would have to convert to UTF-16 for proper answers to .length and array indexing on strings.