Files
30-seconds-of-code/snippets/isObjectLike.md
2022-12-04 22:20:49 +02:00

498 B

title, tags, cover, firstSeen, lastUpdated
title tags cover firstSeen lastUpdated
Value is object-like type,object blog_images/orange-flower.jpg 2018-01-23T19:30:03+02:00 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'.
const isObjectLike = val => val !== null && typeof val === 'object';
isObjectLike({}); // true
isObjectLike([1, 2, 3]); // true
isObjectLike(x => x); // false
isObjectLike(null); // false