On 19 Oct 2013, at 00:53, Domenic Denicola <[email protected]> wrote:

> On 19 Oct 2013, at 01:12, "Mathias Bynens" <[email protected]> wrote:
>> `String.prototype.codePointAt` or `String.prototype.at` come in handy in 
>> case you only need to get the first code point or symbol in a string, for 
>> example.
> 
> Are they useful for anything else, though? For example, if I wanted to get 
> the second symbol in a string, how would I do that?

Yeah, that’s the problem with these methods. Additional user code is required 
to handle non-zero `position` arguments, unless you’re sure the `position` is 
actually the start of a code point (and not in the middle of a surrogate pair). 
I guess there are situations where that’s a certainty, for example when you’re 
dealing with a string in which the user selected some text.

This brings us back to the earlier discussion of whether something like 
`String.prototype.codePoints` should be added: 
http://esdiscuss.org/topic/how-to-count-the-number-of-symbols-in-a-string It 
could be a getter or a generator… Or does `for…of` iteration handle this use 
case adequately?
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to