Add isObjectLike.md

This commit is contained in:
Angelos Chalaris
2018-01-23 19:30:03 +02:00
parent 6c28ff4532
commit 11a4872cf0
2 changed files with 17 additions and 0 deletions

16
snippets/isObjectLike.md Normal file
View File

@ -0,0 +1,16 @@
### isObjectLike
Checks if a value is object-like.
Check if the provided value is not `null` and its `typeof` is equal to `'object'`.
```js
const isObjectLike = val => val !== null && typeof val === 'object';
```
```js
isObjectLike({}); // true
isObjectLike([1, 2, 3]); // true
isObjectLike(x => x); // false
isObjectLike(null); // false
```

View File

@ -101,6 +101,7 @@ isNil:type
isNull:type
isNumber:type,math
isObject:type,object
isObjectLike:type,object
isPlainObject:type,object
isPrime:math
isPrimitive:type,function,array,string