diff --git a/snippets/isObjectLike.md b/snippets/isObjectLike.md new file mode 100644 index 000000000..969fdecd4 --- /dev/null +++ b/snippets/isObjectLike.md @@ -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 +``` diff --git a/tag_database b/tag_database index df181e65a..0673b023a 100644 --- a/tag_database +++ b/tag_database @@ -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