Why does "😀".length return 2 in JavaScript?
JavaScript strings are UTF-16, and any character above U+FFFF (most emoji) is stored as a two-unit surrogate pair. .length counts code units, so it reports 2. Use [...str].length to count code points instead.