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.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

14
  • 71
    In javascript an array is also an object, so most of the time you want to exclude the array: return obj === Object(obj) && Object.prototype.toString.call(obj) !== '[object Array]' Commented Jul 12, 2013 at 8:57
  • 30
    why would you exclude an array? They are full-fledged objects. Commented Apr 8, 2014 at 21:17
  • 93
    Because most of the time you want to distinguish an {} from a [] for example as input in a function Commented Apr 9, 2014 at 9:39
  • 7
    @Nickolai ..and for iterating through nested objects. Commented May 22, 2014 at 1:18
  • 7
    Great answer. Handles null, too. Should be the accepted answer. Commented Nov 17, 2015 at 20:59