Nest all content into snippets
This commit is contained in:
23
snippets/js/s/is-object-like.md
Normal file
23
snippets/js/s/is-object-like.md
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
title: Value is object-like
|
||||
type: snippet
|
||||
language: javascript
|
||||
tags: [type,object]
|
||||
cover: orange-flower
|
||||
dateModified: 2020-09-15T16:28:04+03:00
|
||||
---
|
||||
|
||||
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
|
||||
```
|
||||
Reference in New Issue
Block a user