From 11a4872cf0685725d8f92760b62da877639fe6de Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Tue, 23 Jan 2018 19:30:03 +0200 Subject: [PATCH] Add isObjectLike.md --- snippets/isObjectLike.md | 16 ++++++++++++++++ tag_database | 1 + 2 files changed, 17 insertions(+) create mode 100644 snippets/isObjectLike.md 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