I am trying to understand how emojis work and how does any textarea in my browser handle a seemingly 2 chars represented as one?
"👍".length // -> 2
More examples here: https://jsbin.com/zazexenigi/edit?js,console
In UTF-16 there are 1,112,064 possible characters. Each character uses code points to be represented. In UTF-16 one code-point use two bytes (16 bits) to be saved. This means that with one code point you can have only 65536 different characters.
This means some characters has to be represented with two code points.
String.length() returns the number of code units in the string, not the number of characters.
MDN explains quite well String.length()