Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
3 of 5
Rollback to Revision 1
Nick is tired
  • 7.2k
  • 21
  • 44
  • 55

I think this would work. Function that returns true or false, possibly null.

const isObject = obj => obj && obj.constructor && obj.constructor === Object;

isObject({}) // true
isObject([]) // false
isObject(new Number(123)) // false
isObject(null) // null
pizzarob
  • 12.1k
  • 7
  • 51
  • 70