`String.prototype.symbolAt()` (improved `String.prototype.charAt()`)

Mathias Bynens mathias at qiwi.be
Fri Oct 18 10:30:42 PDT 2013

On 18 Oct 2013, at 11:05, Anne van Kesteren <annevk at annevk.nl> wrote:

> On Fri, Oct 18, 2013 at 4:58 PM, Mathias Bynens <mathias at qiwi.be> wrote:
>> I disagree. In those situations you should just iterate over the string using `for…of`.
> That seems to iterate over code units as far as I can tell.
> for (var x of "💩")
>  print(x.charCodeAt(0))
> invokes print() twice in Gecko.

Woah, that doesn’t seem very useful. Is that a bug, or the way it’s supposed to work? I thought it was supposed to only iterate over whole code points (i.e. only print once for each code point, not once for each surrogate half).

More information about the es-discuss mailing list