How do I view what is in "[object Object]"?

How do I view what is in "[object Object]"?
0

#1

I’m using console.log() and for some items, I’m seeing this [object Object], which makes it difficult to troubleshoot. How can I actually see which object this is referring too?


#2

Press F12 key in your browser(Chrome highly recommended).
And you will see a console.
It will help you lot in your challenges and troubleshooting.
Hope that helps.


#3

"[object Object]" is the default string representation of an object. Once it’s been converted to a string, there’s no way to get info about the original object from that string.

However, console.log-ing an object should not usually convert it to a string. What’s your code? And are you viewing the console through a standard browser such as Chrome, Firefox, etc. or something else?


#4

Good to know, I’ll give that a shot!


#5

Ah, makes sense. I was not viewing it through a browser, I was viewing it through the freeCodeCamp UI (while using chrome).


#6

Use console.log() in the console i told you about.


#7

Hey @dkang17,
Actually every Object have a toString() method in it’s proto .
So, if you like make a object :-

let obj = {};
obj.toString() //"[object Object]"

Then it will gave the string format of the object.
For more method go to your console and type :

obj.__proto__  //gave you the list of all methods

#8

if the other answers didnt help
you can try run a foreach on object keys method
to peel the object layers so u nail the values