well lets say I have a repl with:
let line = "a='𝌆'";
let cursor = line.length - 1; // right after 𝌆
if we backspace we want to remove
𝌆, but there is no way to see how many char codes prior to an index (
cursor in this case ) we need to go back to get to a valid code point.
line.codePointAt(cursor - 1) returns a valid number, even though it is in the middle of
𝌆. The solution is to have a reversed string for now to have the code points line up and prevent having partial surrogate pairs since indexing is based upon char codes, but we want to remove a code point on backspace.
You need the full string for more complex issues than single char deletion, things like word iteration / deletion using regexp.
Update: blurb about why the full string is needed (vs fully doing it manually)