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

Mathias Bynens mathias at qiwi.be
Fri Oct 18 05:46:56 PDT 2013

ES6 fixes `String.fromCharCode` by introducing `String.fromCodePoint`.

Similarly, `String.prototype.charCodeAt` is fixed by `String.prototype.codePointAt`.

Should there be a method that is like `String.prototype.charAt` except it deals with astral Unicode symbols wherever possible?

    >> '𝌆'.charAt(0) // U+1D306
    '\uD834' // the first surrogate half for U+1D306

    >> '𝌆'.symbolAt(0) // U+1D306
    '𝌆' // U+1D306

Has this been discussed before? If there’s any interest I’d be happy to create a strawman.


More information about the es-discuss mailing list