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

  • Home
  • SEARCH
  • 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 9034639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:32:21+00:00 2026-06-16T08:32:21+00:00

On page load I am creating two Javascript Objects, objDemo1 and objDemo1Backup where the

  • 0

On page load I am creating two Javascript Objects, objDemo1 and objDemo1Backup where the latter is simply an exact copy of the first.

e.g.

objDemo1 { 
    sub_1 = { something: 123, somethingElse: 321 },
    sub_2 = { something: 456, somethingElse: 654 }
}

I can modify the values in sub_ as well as add / delete new sub_‘s but the only object I am editing is objDemo1. i.e. I never change objDemo1Backup

I have a reset button that when clicked will reset objDemo1 back to what it was when the page originally loaded (i.e. objDemo1 = objDemo1Backup). This is where I am having the issue..

How do I set objDemo1 to objDemo1Backup?

I have tried:

objDemo1 = objDemo1Backup;

and

objDemo1 = null;
var objDemo1 = objDemo1Backup;

…as well as similar variations but nothing seems to work.
Any ideas?

  • Note: I can confirm that at the point of resetting, objDemo1Backup is exactly the same as it was when I created it and objDemo1 has changed.
  • My code is definetly hitting the “reset” functionality, where I’ve tried the objDemo1 = objDemo1Backup… I just cannot figure out the syntax to replace the object.
  • 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-16T08:32:23+00:00Added an answer on June 16, 2026 at 8:32 am

    In JavaScript objects are passed by reference, never by value. So:

    var objDemo, objDemoBackup;
    objDemo = {
        sub_1: "foo";
    };
    objDemoBackup = objDemo;
    objDemo.sub_2 = "bar";
    console.log(objDemoBackup.sub_2);   // "bar"
    

    To get a copy, you must use a copy function. JavaScript doesn’t have one natively but here is a clone implementation: How do I correctly clone a JavaScript object?

    var objDemo, objDemoBackup;
    objDemo = {
        sub_1: "foo";
    };
    objDemoBackup = clone(objDemo);
    objDemo.sub_2 = "bar";
    console.log(objDemoBackup.sub_2);   // undefined
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my page load I check something, and I want to display the standard
I have two DataTables objects on a page, lets call them searchResultsTable and currentPortfolioTable.
I'm having a problem with Symfony creating a new session on each page load,
I have an ASPX page where in the page load i am dynamically creating
On page load I'm bootstrapping my data to my collections via this technique .
Is Page.Load the earliest point in the Page.Load life cycle to add Response.AppendHeader?
Q1) On page load is it possible with Jquery to check the file name
In my page load, am I calling ReturnStuff() once or three times? If I
I want on page load for the class of a li tag to be
I'm trying to log page visits and count number of visitors. I have two

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.