Merge pull request #389 from kriadmin/master

Add a snippet byteSize
This commit is contained in:
Angelos Chalaris
2017-12-29 14:58:28 +02:00
committed by GitHub

14
snippets/byteSize.md Normal file
View File

@ -0,0 +1,14 @@
### byteSize
Returns the length of string.
Convert a given string to a [`Blob` Object](https://developer.mozilla.org/en-US/docs/Web/API/Blob) and find its `size`.
```js
const byteSize = str => new Blob([str]).size;
```
```js
byteSize("😀"); // 4
byteSize("Hello World"); // 11
```