On Oct 18, 2013, at 10:06 AM, Andrea Giammarchi wrote:
> +1 for the simplified `at(symbolIndex)`
>
> I would expect '𝌆'.at(1) to fail same way 'a'.charAt(1) or 'a'.charCodeAt(1)
> would.
They are comparable, as the 'a' example are "index out of bounds" errors. We
only use code unit indices with strings so '𝌆'[1] is valid (and so presumably
should be '𝌆'.at(1) with 1 having the same meaning in each case.
The most consistent way to define String.prototype.at be be:
String.prototype.at = function(pos} {
let cp = this.codePointAt(pos);
return cp===undefined ? undefined : String.fromCodePoint(cp)
}
Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss