JSFiddle - React, Tailwind, and code Playground

HTML

<span id="testElement" class="testClass" data-check="check">Test element attributes:</span>
<span id="attrs"></span>

JavaScript

(function () {
    Element.prototype.getAttributes = function() {
        return (function (node) {
            var attrs = {};
            for (var i=0;i<node.length;i++) {
                attrs[node.item(i).name] = node.item(i).value;
            }
            return attrs;
        })(this.attributes);
    };
})();

var attrs = document.getElementById("testElement").getAttributes();
document.getElementById('attrs').innerHTML = JSON.stringify(attrs);