The following code takes in an element, taken from the DOM and the second variable is a predefined empty object. The LHS of the final line create an attribute within the attributes object then the RHS fetches the same attribute from the myEl and assigns it to the LHS. or should do. Expected output is new object with attribute id, for example, equals the id attribute of the element passed in.
function getAttributes(myEl, myObj){
attArray = [
"tagName",
"id",
"name"
];
for (var att in attArray){
if (myEl.hasOwnProperty(attArray[att])) {
myObj.attributes = {};
myObj.attributes.hasOwnProperty(attArray[att]) == myEl.hasOwnProperty(attArray[att]);
};
};
};