title: Cloning an event object in Javascript/jQuery
body: <p>How can I create a completely separate and new event object that contains all of the same exact properties as a given event object <code>e</code>.  So far I've tried the following but no luck:</p>
  <pre><code>function myHandler(e) {
     // ...
  
     e = e.originalEvent;
  
     // method 1
     var e2 = jQuery.extend(true, {}, e);
  
     // method 2
     var e2 = JSON.parse(JSON.stringify(e));
  
     // ...
  }
  </code></pre>
  <p>EDIT: I will add more details to help clarify.  Very similar to this <a href="https://stackoverflow.com/questions/12176724/">question</a> I am trying to do: <code>div.dispatchEvent(e.originalEvent)</code>, but doing so results in:</p>
  <blockquote>
  <p>DISPATCH_REQUEST_ERR: DISPATCH_REQUEST_ERR: DOM Events Exception 1</p>
  </blockquote>
  <p>so in order to avoid this, I need to duplicate the event object.  However, this event object isn't a specific one (i.e., sometimes the <code>e</code> is a <code>touchstart</code>, <code>touchmove</code>, or <code>touchend</code>) and therefore it'd be easier if I could get a general cloning function instead of just hard coding the specific properties.  What I meant by &quot;no luck&quot; was that by trying the aforementioned methods and sending that thru the dispatch function I was getting errors.  Hope this helps clarify a bit.</p>