Tuesday, 25 August 2020

How to show full object in Chrome console?

Hello Friends,  

In this article, I will explain How to show the full objects in Chrome console?

In the last week, I was working with one angular project where i want to show the full object in chrome console.


I used console.log but it was not showing full object in Chrome console




Solution:

Use console.dir() to output a browse-able object . Prints a JavaScript representation of the specified object. If the object being logged is an HTML element, then the properties of its DOM representation are printed [1]

In *most* cases, console.log is the method you'd want to use to log something into the console. In some cases, however, console.dir can come a little more handy!

With console.dir, you can explore a regex's properties. When working with DOM elements console.log will display an HTML nested structure, compared to console.dir which will treat them as objects.

console.dir(object);
OR
console.log(JSON.stringify(object))


Prints a JSON representation of the specified object.



Example:



console.dir() should be used to get more information like prototype etc in arrays and objects.

Hope this helped you to solve your error
Happy Programming!!
Don’t forget to leave your feedback and comments below!
If you have any query mail me to Sujeet.bhujbal@gmail.com     
Happy programming!!
Don’t forget to leave your feedback and comments below!
Regards
Sujeet Bhujbal
--------------------------------------------------------------------------------
------------------------------------------------------------------------------

0 comments:

Post a comment