42

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.?

Michael Irigoyen
  • 22,513
  • 17
  • 89
  • 131
StephenPAdams
  • 2,797
  • 2
  • 30
  • 49
  • 3
    possible duplicate of [How do I dump JavaScript vars in IE8?](http://stackoverflow.com/questions/1956384/how-do-i-dump-javascript-vars-in-ie8) – fresskoma Oct 31 '12 at 11:46
  • http://stackoverflow.com/questions/1306232/how-to-debug-javascript-with-ie-8 – ColacX Feb 02 '15 at 10:54

4 Answers4

52

You might want to try:

console.log(JSON.stringify(foobarObject));
jeffjenx
  • 17,041
  • 6
  • 57
  • 99
Andy
  • 1,778
  • 1
  • 11
  • 9
  • 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 – Chris Nelson Apr 15 '10 at 20:13
  • 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. – Andy Dec 15 '11 at 10:11
  • does not print anything for xml object, but `console.dir(obj);` does – Sasha Bond Jul 01 '18 at 00:24
32

Use:

console.dir(obj); 

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

heinob
  • 19,127
  • 5
  • 41
  • 61
  • 8
    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] } – Jacob van Lingen Nov 27 '13 at 08:24
  • Yes, not so useful for any objects which are classes, etc. – brianlmerritt Jun 29 '16 at 15:00
11

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

Community
  • 1
  • 1
Gonçalo Queirós
  • 1,193
  • 2
  • 9
  • 19
0

Add the object to watch and you can see and analyze it completely from watch panel.

Prateek Batla
  • 1,972
  • 1
  • 11
  • 8