Update size.md
This commit is contained in:
@ -2,7 +2,12 @@
|
|||||||
|
|
||||||
Get size of arrays, objects or strings.
|
Get size of arrays, objects or strings.
|
||||||
|
|
||||||
Get type of value – array, object and string. Use `length` property for arrays. Return `length` or `size` value if available or number of object keys. Split strings into array of characters with `split('')` and return its length.
|
Get type of `value` (`array`, `object` or `string`).
|
||||||
|
Use `length` property for arrays.
|
||||||
|
Use `length` or `size` value if available or number of keys for objects.
|
||||||
|
Use `size` of a [`Blob` object](https://developer.mozilla.org/en-US/docs/Web/API/Blob) created from `value` for strings.
|
||||||
|
|
||||||
|
Split strings into array of characters with `split('')` and return its length.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const size = value =>
|
const size = value =>
|
||||||
@ -11,7 +16,7 @@ const size = value =>
|
|||||||
: value && typeof value === 'object'
|
: value && typeof value === 'object'
|
||||||
? value.size || value.length || Object.keys(value).length
|
? value.size || value.length || Object.keys(value).length
|
||||||
: typeof value === 'string'
|
: typeof value === 'string'
|
||||||
? value.split('').length
|
? new Blob([value]).size
|
||||||
: 0;
|
: 0;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user