how to check if attribute exists in javascript code example Example: how to check element has an attribute js let result = element.hasAttribute(name);