Files
30-seconds-of-code/snippets/byteSize.md
2017-12-29 18:22:30 +05:30

288 B

byteSize

Returns the length of string.

It converts a given string to a Blob Object and finds it's size

const byteSize = str => new Blob([str]).size;
byteSize("😀"); // 4
byteSize("Hello World"); // 11