Open this example in the interactive library
Source code
const text = "A😀B";
console.log(text.length, Array.from(text).length);
Sample output
4 3

Count Unicode code points. A self-contained example using the JavaScript runtime.
Open this example in the interactive library
const text = "A😀B";
console.log(text.length, Array.from(text).length);
4 3