`String.prototype.symbolAt()` (improved `String.prototype.charAt()`)
mathias at qiwi.be
Fri Feb 14 02:51:09 PST 2014
On 14 Feb 2014, at 11:14, C. Scott Ananian <ecmascript at cscott.net> wrote:
> Note that `Array.from(str)` and `str[Symbol.iterator]` overlap
> significantly. In particular, it's somewhat awkward to iterate over
> code points using `String#symbolAt`; it's much easier to use
> `substr()` and then use the StringIterator.
`String#at` is not meant for iterating over code points – that’s what the `StringIterator` is for.
`String#at` is exactly like `String#codePointAt` except it returns strings (containing the symbol) instead of numbers (representing the code point value). It can be used to get the symbol at a given code unit position in a string (similar to how `String#codePointAt` can be used to get the code point at a given code unit position in a string).
More information about the es-discuss