Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 589
StephenPAdams Avatar asked Mar 12 '10 17:03

StephenPAdams


People also ask

How do you display an object in console log?

Answer: Use console. log() or JSON. stringify() Method This method will print the object in browser console.

What is object object in 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.

How do you console an object in JavaScript?

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()


2 Answers

You might want to try:

console.log(JSON.stringify(foobarObject)); 
like image 100
Andy Avatar answered Sep 24 '22 00:09

Andy


Use:

console.dir(obj);  

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

like image 40
heinob Avatar answered Sep 23 '22 00:09

heinob