title: How to pass persistent data to addEventListener in javascript?
body: <p>In javascript I can do this:</p>
  
  <pre><code>var mydata = {foo:"bar"};
  element.addEventListener("click", myFunc);
  
  function myFunc(e) {
      // need to get {foo:"bar"}
  }
  </code></pre>
  
  <p>I want to access the <code>mydata</code> variable from the myFunc function, but passed as parameter data, whenever the click event happens in the element. I don't want to get it through some global variable. I want to get that data passed in somehow. Something like this, if it existed:</p>
  
  <pre><code>var mydata = {foo:"bar"};
  element.addEventListener("click", mydata, myFunc);
  
  function myFunc(e) {
      var mydata = e.data;
  }
  </code></pre>
  
  <p>Does anyone know a way? And no, you can't use jquery or any plugins.</p>
  
  <p>Thanks</p>