// Do this:
// This always returns a boolean value
const isObject = (obj) => !!obj && typeof obj === "object";
// Or this:
const isObject = (obj) => Boolean(obj) && typeof obj === "object";
// Or this:
const isObject = (obj) => obj !== null && typeof obj === "object";
// Instead of this:
// This may return falsy values that are not equal to false
const isObject = (obj) => obj && typeof obj === "object";Boolean / notebook
Boolean
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.