js check if attribute exists

JavaScript
        
            
        
     let result = element.hasAttribute(name);

Source

Also in JavaScript: