Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8582671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:21:01+00:00 2026-06-11T21:21:01+00:00

Anybody know how to do a deep copy/cloning of a native javascript event object?

  • 0

Anybody know how to do a deep copy/cloning of a native javascript event object? I know I can create a new event object and set the appropriate properties manually to match the original event, but it’d be much easier if there’s a way to just clone.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:21:02+00:00Added an answer on June 11, 2026 at 9:21 pm

    For your purposes I’d just make it a prototype of a new object constructor and override the ones you want changed. Cloning in JS gets messy due to the circular reference issue so it may not be the quick and dirty solution you were hoping for.

    function cloneEventObj(eventObj, overrideObj){
    
       if(!overrideObj){ overrideObj = {}; }
    
       function EventCloneFactory(overProps){
           for(var x in overProps){
               this[x] = overProps[x];
           }
        }
    
        EventCloneFactory.prototype = eventObj;
    
        return new EventCloneFactory(overrideObj);
    
    }
    
    //So add your override properties via an object
    $el.click(function(e){
        var newEventObj = cloneEventObj(
            e,
            { target:document.body }
        );
        doSomething(newEventObj);
    });
    
    //or just stick 'em on manually after spitting the object out
    /*...
    var newEventObj = cloneEventObj(e);
    newEventObj.target = document.body
    ...*/
    

    In this case the ‘cloned’ object is the prototype object of the new object. ‘this.’ properties are checked for before the prototype object so these will override. Or you could just attach properties after the object is built.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anybody know how I can create an In restriction using Linq to NHibernate. i.e.
anybody know how can I replace \ by \\ ? input string : Télephone
Anybody know of a way to batch NHibernate queries using NHibernate.Linq like you can
Anybody know if it's possible to; Dynamically create LINQ classes for tables/columns that change
Anybody know where I can find a table of browsers and whether or not
Anybody know of a ready-made php class which can read a file-system directory recursively
Anybody know how can I add multiple email addresses in Outlook field To via
Does anybody know a way to enable response character set selection by client for
Anybody know a way to resolve an object out of an IOC container, particularly
Anybody know how to create code snippets in Mozilla Bespin. Its strange that there's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.