Last Updated: September 09, 2019
·
4.116K
· thomaslindstr_m

How to log JavaScript element representations in the console

Have you ever tried logging, say, DOM elements to inspect them in the console using console.log, and then seen something like this:

Picture

In some occasions this is enough, but what if you'd like to inspect the JavaScript representation of the element?

Picture

This is done easily by using another native function called console.dir instead

var logo = document.getElementById('hplogo');
console.dir(logo);

Neat!