How To Get The Number Of Bytes In A String In JavaScript

Last modified on Tuesday 25 Jan 2022 at 05:41 am

Getting the number of bytes in a Frontend or Node.js JavaScript string can be very useful.

For example, one reason it’s very useful is that Twitter limits posts to 280 bytes, not necessarily 280 characters. If you use just Latin characters, numbers, or other ASCII characters in a Twitter post, then the number of characters would be equal to the number of bytes since each ASCII character is made with 1 byte. Continue reading “How To Get The Number Of Bytes In A String In JavaScript”