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.?
Answer: Use console. log() or JSON. stringify() Method This method will print the object in browser console.
[object Object] is a string representation of an object. You may see this text if you use alert() to print an object to the screen, for instance. You can view the contents of an object using console. log(), JSON. stringify(), or a for…in loop.
Console object In JavaScript, the console is an object which provides access to the browser debugging console. We can open a console in web browser by using: Ctrl + Shift + I for windows and Command + Option + K for Mac. The console object provides us with several different methods, like : log()
You might want to try:
console.log(JSON.stringify(foobarObject));
Use:
console.dir(obj);
This will will give you all properties of the object also in IE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With