element.hasAttribute(name) is the standard method to check if an element has a specific attribute. It returns a boolean value: true if the attribute exists, false if it doesn't. This method is more efficient than checking getAttribute() !== null because it doesn't need to retrieve the attribute's value. It works with both standard HTML attributes and custom data attributes.