So my dilemma is that I don\'t want to write the same code twice. Once for the click event and another for the touchstart event.
Here is the original co
I know this is an old question, but I thought some might find this approach useful; it could be applied to any similarly repetitive code:
ES6
['click','ontouchstart'].forEach( evt =>
element.addEventListener(evt, dosomething, false)
);
ES5
['click','ontouchstart'].forEach( function(evt) {
element.addEventListener(evt, dosomething, false);
});