An Interest In:
Web News this Week
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
- April 19, 2024
- April 18, 2024
May 17, 2022 05:40 am GMT
Original Link: https://dev.to/koladev/dont-use-consolelog-to-log-a-list-of-objects-1nga
Don't Use Console.log to Log a List of Objects!
When debugging your JavaScript application, console.log()
is one of the most valuable methods to log into the browser console for the value of an object or anything.
But it's pretty challenging to navigate when displaying a list of objects.
For example, let's console log this data.
const data = [ { "_id": "628332c6b14a04d1708be802", "index": 0, "guid": "61ec3d19-f7f3-4083-8bef-b9042c881c79", "isActive": true }, { "_id": "628332c61dc4ecd57ae4f6fd", "index": 1, "guid": "49ea2d62-afec-4f62-9eae-0890a94462e3", "isActive": true }, { "_id": "628332c6391c257b04b3c574", "index": 2, "guid": "a7f2240b-5b9b-4786-8b9d-92307f313349", "isActive": true }, { "_id": "628332c66e1d9b58e696e38f", "index": 3, "guid": "b52e0d56-28d8-418f-a30f-e431b7fcaa20", "isActive": true }, { "_id": "628332c676d375dc108e0f28", "index": 4, "guid": "e37e0f56-1c35-4f59-bb12-eda874be49fb", "isActive": false }]
And now let's use console.table(data)
instead.
The data is much more readable and navigable. You can learn more about console.table
here.
Article posted using bloggu.io. Try it for free.
Original Link: https://dev.to/koladev/dont-use-consolelog-to-log-a-list-of-objects-1nga
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To