I needed this small function for one of my project.
function fetchAttrs(node) {
if (!node || !node.hasAttributes()) return {};
var attrs = node.attributes;
var res = {};
var length = attrs.length;
for (i = 0; i < length; i++) {
var attr = attrs[i];
res[attr.name] = attr.value;
}
return res;
}
Its working fine as expected but I wanted to know if I am missing something from performance point of view or good coding practices. Just need a second opinion :)