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*

11
  • 19
    I recently learned that typeof [] === 'object' --> true. That's what you need this method. Commented Aug 11, 2013 at 5:29
  • 5
    @Christophe Doesn't distinguish between primitives and objects. Object.prototype.toString.call(3) -> "[object Number]". Object.prototype.toString.call(new Number(3)) -> "[object Number]" Commented Mar 18, 2014 at 17:25
  • 9
    @MattFenwick I don't think this is the kind of "object" the OP is trying to identify Commented Mar 19, 2014 at 5:21
  • 3
    @Christophe why do you think that? IMHO, in the absence of any other definition given by the OP for "object", it seems most reasonable to me to go with the one that is used consistently throughout the ECS spec. Commented Mar 19, 2014 at 11:36
  • getType=function(obj){return Object.prototype.toString.call(obj).match(/\[object (\w+)\]/)[1];}; Commented Nov 17, 2014 at 22:08