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
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️