Files
30-seconds-of-code/snippets/is-object-like.md
2023-04-28 22:29:23 +03:00

462 B

title, type, tags, cover, dateModified
title type tags cover dateModified
Value is object-like snippet
type
object
orange-flower 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