title: Add callback to .addEventListener
body: <p>Suppose I have this straightforward event listener registration pattern:</p>
  
  <pre><code> function registerElement(){
       var element = document.getElementById("element");
       element.addEventListener("click", sayHello, false);
   }
  
   function sayHello(event){
       event.preventDefault();
       console.log("Hello from " + this.id);
   }
  
   registerElement();
  </code></pre>
  
  <p>Now, I'd like to add a callback function, say registerElement(callback). The idea is to execute some function after "element" gets a click, and the pseudocode might look something like this:</p>
  
  <pre><code> function registerElement(callback){
       var element = document.getElementById("element");
       element.addEventListener("click", sayHello, false); //&lt;--not sure what to do here to add callback to sayHello
   }
  
   function sayHello(event, callback){
       event.preventDefault();
       console.log("Hello from " + this.id);
       callback;
   }
  
   function cleanup(){
       console.log("Hello from cleanup");
   }
  
   registerElement(cleanup);
  </code></pre>
  
  <p>I'm trying to avoid using an anonymous function in registerElement to make sayHello() more reusable. I looked at bind, but that seems to focus on controlling which "this" gets sent over to the event listener function. Any other ideas? </p>
  
  <p>Thanks for tips!</p>