identify the type of an object  [ 211 views ]

Goal: simple way to check the type of a page object

I have found many answers about this question but the useless is much more than the valuable. There is a simple way to identify objects on the page.
For example I have a click listener and I want to know the type of the target object:

$(document).on({
  click: function(event){
    console.log(event.target, event.target.nodeName);
  }
});

No more like this. You can list all of the object types on your page with the following code piece

var all = document.getElementsByTagName("*"), a = [];
for (var item of all) {
  var nn = item.nodeName;
  !a[nn] && (a[nn] = nn);
}
console.log(a);
console.log(Object.keys(a).toString());
-> HTML,HEAD,META,TITLE,LINK,SCRIPT,BODY,STYLE,DIV,SPAN,IMG,UL,LI,BR,SELECT,OPTION,I,B,A,CANVAS
#sidebar a { color:#fff; } #sidebar ul ul li { color: #DEF585; } #sidebar h2 { color: #fff; } #sidebar ul p, #sidebar ul select { color: #BEDDBE; } #backfly { background: url(images/golfBallWallPaper.jpg) left bottom fixed repeat-x #65a51d; }