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.
4 of 4
Added a shorter option
Gust van de Wal
  • 5.3k
  • 1
  • 27
  • 52

If you would like to check if the prototype for an object solely comes from Object. Filters out String, Number, Array, Arguments, etc.

function isObject (n) {
  return Object.prototype.toString.call(n) === '[object Object]';
}

Or as a single-expression arrow function (ES6+)

const isObject = n => Object.prototype.toString.call(n) === '[object Object]'
sasi
  • 322
  • 2
  • 9