I needed this small function for one of my project.Fetch Attributesfunction fetchAttrs(node) {  if (!node || !node.hasAttributes()) return {};  var attrs = node.attributes;  var res = {};  var length = attrs.length;  for (var i = 0; i < length; i++) {    var attr = attrs[i];    res[attr.name] = attr.value;  }  return res;}It's working fine as expected but I wanted to know if I am missing something from a performance point of view or good coding practices. Just need a second opinion :)UpdateHow to handle exceptions, is it a good practice?
Get all the attributes of a DOM Node
javascript;dom