Menu

gitpiper

byteSize javascript Code Snippet in 2024

stringbeginner

Last Updated: 20 June 2024

Returns the length of a string in bytes.

  • Convert a given string to a Blob Object.
  • Use Blob.size to get the length of the string in bytes.
const byteSize = str => new Blob([str]).size;
byteSize('😀'); // 4 byteSize('Hello World'); // 11

javascript snippet similar to byteSize For You in June 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️