Console.log in IE on an object just outputted [object Object]

44,421

Solution 1

Maybe you can try what Xavi suggested here: How do I dump JavaScript vars in IE8?

Solution 2

You might want to try:

console.log(JSON.stringify(foobarObject));

Solution 3

Use:

console.dir(obj); 

This will will give you all properties of the object also in IE.

Share:
44,421
StephenPAdams
Author by

StephenPAdams

Developer, father and husband with a constant eye on technology.

Updated on July 09, 2022

Comments

  • StephenPAdams
    StephenPAdams almost 2 years

    I'm used to debugging JavaScript in Chrome or Firefox just because their built in developer tools are a lot cleaner than IE's. IE8 came along way with the Developer Tools being more polished, but they're still not completely up to snuff. I like being able to step through code as if I was in Visual Studio, and that is pretty nice about IE, however, when trying to do a simple console.log on an object that I have, in Firefox/Chrome/etc. I can actually explore that object.

    In IE, the console is simply outputting the following:

    LOG: [object Object]

    Is there any way to drill down into that object in IE like in Chrome/Firefox/etc.?

  • ylva
    ylva about 14 years
    Maybe I'm understanding this wrong but if I type "console.log('foo')" into the entry field at the bottom of the console window, the console (text area above) says: >>console.log('foo') undefined
  • StephenPAdams
    StephenPAdams about 14 years
    Yeah, this is great for debugging, but not completely what I was looking for.
  • Andy
    Andy over 12 years
    It should also have the message "LOG: foo". console.log returns undefined which is what it outputs in the console as well. In IE9 that was changed to not show undefined results in the console.
  • mikemaccana
    mikemaccana about 11 years
    Could you add the answer to your questions? Other sites go down, change etc, and can't be edited.
  • Jacob van Lingen
    Jacob van Lingen over 10 years
    Note: console.dir shows only the first level of properties. So when you would create var a = { a: 'b', b : { a: 'b', b : 'c'}}, the result of console.dir(a) would be: { a : "b", b : [object Object] }
  • brianlmerritt
    brianlmerritt almost 8 years
    Yes, not so useful for any objects which are classes, etc.
  • Sasha Bond
    Sasha Bond almost 6 years
    does not print anything for xml object, but console.dir(obj); does