Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

At least the “of” loop returns what is selectable via a cursor in the browser. I think…


Yeah; its really confusing but javascript - for legacy reasons - treats strings as "arrays of UCS2 items". But javascript also implements iterator on strings which iterate through strings in unicode codepoints. Thats why "of" loops work differently from "in" loops. (for-of in javascript uses Symbol.iterator). That also means you can pull a string apart into an array of unicode codepoints using [...somestring].




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: