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.
2 of 4
Fixed unnecessary explicit return value.
sasi
  • 322
  • 2
  • 9

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) {
  if (n == null) return false;
  return Object.prototype.toString.call(n) === '[object Object]';
}
sasi
  • 322
  • 2
  • 9