How do you check if a value is an object in JavaScript?
Here's an answer with optional chaining, and perhaps the smallest isObj
function for this question.
const isObj = o => o?.constructor === Object;
// True for this
console.log(isObj({})); // object!
// False for these
console.log(isObj(0)); // number
console.log(isObj([])); // array
console.log(isObj('lol')); // string
console.log(isObj(null)); // null
console.log(isObj(undefined)); // undefined
console.log(isObj(() => {})); // function
console.log(isObj(Object)); // class