What is the output?
console.log([...'héllo'].length, '😀'.length);
- 5 1
- 6 2
- 5 2
- 6 1
Spreading iterates by code point (5), but .length counts UTF-16 units and the emoji is a surrogate pair.
Play Problem Solving ▸
console.log([...'héllo'].length, '😀'.length);