# String.prototype.codePoints()

**URL:** <https://es.discourse.group/t/string-prototype-codepoints/1198>\
**Category:** 💡 Ideas\
**Tags:** proposal\
**Created:** [February 11, 2022, 2:22pm UTC](https://es.discourse.group/t/string-prototype-codepoints/1198 "2022-02-11T14:22:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![graphemecluster](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/graphemecluster/32/957_2.png) [@graphemecluster](https://es.discourse.group/u/graphemecluster)\
**Post date:** [February 11, 2022, 2:22pm UTC](https://es.discourse.group/t/string-prototype-codepoints/1198/1 "2022-02-11T14:22:07Z")

</div>

While manipulating strings, I often need to loop though the character code instead of their characters. Current we can do `Array.from(str, c => c.codePointAt(0))` or `[...str].map(c => c.codePointAt(0))`, but (1) it’s verbose, (2) unintuitive and (3) I am using TypeScript, so I will need a non-null assertion `c.charCodeAt(0)!` in strict mode, but without a “no non-null assertion” rule, ESLint starts complaining as using non-null assertion is considered a bad practice.

So I am here to propose the `String.prototype.codePoints()` (and possibly also the `String.prototype.charCodes()`) method.

---

<div class="post-metadata">

**Author:** ![ljharb](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ljharb/32/8_2.png) [@ljharb](https://es.discourse.group/u/ljharb)\
**Post date:** [February 11, 2022, 5:27pm UTC](https://es.discourse.group/t/string-prototype-codepoints/1198/2 "2022-02-11T17:27:55Z")

</div>

[https://github.com/tc39/proposal-string-prototype-codepoints](https://github.com/tc39/proposal-string-prototype-codepoints)

---

<div class="post-metadata">

**Author:** ![graphemecluster](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/graphemecluster/32/957_2.png) [@graphemecluster](https://es.discourse.group/u/graphemecluster)\
**Post date:** [February 12, 2022, 1:04am UTC](https://es.discourse.group/t/string-prototype-codepoints/1198/3 "2022-02-12T01:04:54Z")

</div>

My apologies, I shall have searched thoroughly before making any post.
