Console.log in IE on an object just outputted [object Object]
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.
StephenPAdams
Developer, father and husband with a constant eye on technology.
Updated on July 09, 2022Comments
-
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 about 14 yearsMaybe 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 about 14 yearsYeah, this is great for debugging, but not completely what I was looking for.
-
Andy over 12 yearsIt 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 about 11 yearsCould you add the answer to your questions? Other sites go down, change etc, and can't be edited.
-
Jacob van Lingen over 10 yearsNote: 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 almost 8 yearsYes, not so useful for any objects which are classes, etc.
-
Sasha Bond almost 6 yearsdoes not print anything for xml object, but
console.dir(obj);
does