If you have been a programmer for more than a day, then you have used a console.log
to display data. You may want to see the value of data while your programming running or you may be trying to troubleshoot a problem. Sometimes the data displayed in the console can be a challenge to read. I will show you some methods to make the display of the data more readable.
The biggest challenge in using a console.log is when you want to display data that is an array or an object. By default, this data does not display very well in the console.
For example, you have this array:
[ { school: 'University of Georgia', mascot: 'UGA', students: 37606, location: 'Athens, GA' }, { school: 'University of Georgia Tech', mascot: 'Yellow Jackets', students: 26839, location: 'Atlanta, GA' }, { school: 'Georgia Southern University', mascot: 'Eagles', students: 20517, location: 'Statesboro, GA' } ]
If you console.log
this array, this is what you see in the console:
If you actually want to see the data you have to expand the data and you see this:
This display the entire content of each object on a single line. This is not very helpful if there are a large number of entries in your object.