Echo JS 0.11.0

<~>
MaxArt 127 days ago. link 2 points
> Using the split() method

> let characters = message.split('');
> console.log(characters.length); 

> Using the slice() method

> let characters = message.slice();
> console.log(characters.length);

Is this a joke? Or just a way to collect Medium reactions?

Replies

tracker1 126 days ago. link 2 points
Definitely not a great article... as it is, the Unicode character and surrogate detection isn't great, and even then doesn't really work right with the regexp for non-unicode surrogates.  The notation of byte length should probably be a blurb and jump right into the Unicode detection, surrogates being another, related issue, and even then, it's problematic at best.

Not to mention the benchmark at the end is kind of useless and doesn't include the Unicode aware methods.  Also, no mention of UCS-16 vs UTF-8 or other Unicode demarkation with strings in JS.

Definitely click-bait.