I needed this small function for one of my project. [Fetch Attributes](http://jsbin.com/yuyajidaja/1/edit?html,js,console,output) function 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 :)