r/JavaScriptTips • • Jul 15 '19

Use console.table() to log arrays, objects and nodelists in an organised view

Instead of console.log() you can use:

  • console.table(list) // table of all items and all columns

  • console.table(list, ['columnX', 'columnY', 'columnZ') // table restricted to set columns (very useful for NodeLists)

  • console.table(list, 'columnX') // table restricted to one column

Hit F12 and copy the below into the console:

console.table(document.querySelectorAll('a'), ['innerText', 'href'])

10 Upvotes

0 comments sorted by