`String.prototype.symbolAt()` (improved `String.prototype.charAt()`)
mathias at qiwi.be
Fri Oct 18 13:30:20 PDT 2013
Please ignore my previous email; it has been answered already. (It was a draft I wrote up this morning before I lost my internet connection.)
On 18 Oct 2013, at 11:57, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:
> Given that we have charAt, charCodeAt and codePointAt, I think the most appropiate name for such a method would be 'at':
> The issue when this sort of method has been discussed in the past has been what to do when you index at a trailing surrogate possition:
> do you still get '𝌆' or do you get the equivalent of String.fromCharCode('𝌆') ?
In my proposal it would return the equivalent of `String.fromCharCode('𝌆')`. I think that’s the most sane behavior in that case. This also mimics the way `String.codePointAt` works in such a case.
Here’s a prollyfill for `String.prototype.at` based on my earlier proposal: https://github.com/mathiasbynens/String.prototype.at Tests: https://github.com/mathiasbynens/String.prototype.at/blob/master/tests/tests.js
More information about the es-discuss