How to count the number of symbols in a string?

Mathias Bynens mathias at
Fri Nov 30 12:54:32 PST 2012

Thanks for the useful info, Andrea and Yusuke!

A `{code}points` property/getter on the `String.prototype` like Andrea suggested earlier sure sounds good to me.

IMHO a solution to the “string length” problem should definitely be added to ES6, as even major sites like are doing it wrong currently. Here’s a screenshot of the tweet textarea containing only a single astral symbol: Note how the counter below says “138 [characters left]” instead of 139, as it should.

More information about the es-discuss mailing list