Quantcast
Viewing all articles
Browse latest Browse all 19

Answer by Zoran for String length in bytes in JavaScript

sizeInBytes = Buffer.from(data).length

Example:

let data = 'šč'; // data with utf-8 charactersconsole.log( data.length ); // 2console.log( Buffer.from(data).length ); // 4

Viewing all articles
Browse latest Browse all 19

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>