JSFiddle - React, Tailwind, and code Playground

by Brian Dukes

HTML

<div id="div"></div>

JavaScript

var SomeThing = function (element) {
    this.Element = element;
},
    theThing = new SomeThing(document.getElementById('div')),
    emptyThing = new SomeThing(document.getElementById('abcdef'));

try {
    if (typeof emptyThing.Element.getAttribute !== "undefined") {
        alert("we've got an attribute");
    } else {
        alert('no attribute');
    }
}
catch (exc) {
    alert('not so fast: ' + exc);
}