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 3955914
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:17:52+00:00 2026-05-20T02:17:52+00:00

I have an object called apples and if i do something like apples[0].weight it

  • 0

I have an object called apples and if i do something like apples[0].weight it returns a value. Now I want to be able to store an array of apples. Lets call the array myApples. How do I add multiple instances of apples to the myApples array without the values changing to the most updated one. For example:

apples[0].weight = 10;
apples[1].weight = 20;
myApples.push(apples);
apples[0].weight = 15;
apples[1].weight = 16;
myApples.push(apples);

Now if I were to print the value myApples[0].apples[0].weight i get 15 instead of getting 10. I think its because the reference is the same array, so it gets updated every time I change it. How would I go about storing these apple “states” so I can keep a history of changes made to it. Keep in mind I want to make this arbitrary, so I wouldnt have to make something like apples1, apples2, apples3, because the changes on this could be unlimited.(In my actual project I am storing pinpoints on a canvas, so i can basically do an “undo” and “redo” feature and want to store the values of these pinpoints every time something changes on the canvas.)

EDIT-
This is how I make apples or pinpoints:

var options = {pinpoints: [ { "top": 50,
                           "left": 280,
                           "width": 200,
                           "height": 200},
                         { "top": 0,
                           "left": 0,
                           "width": 300,
                           "height": 74 } ]}    
var optionConfig = $.extend({}, $.fn.mapImage.defaults, options);
var myPinpoints = optionConfig.pinpoints;

So if i do myPinpoints[0].left it gives me 280, I want to be able to push myPinpoints into an array then change myPinpoints[0].left to something else, and then push it on to the array again and save BOTH values

  • 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-05-20T02:17:52+00:00Added an answer on May 20, 2026 at 2:17 am

    You can use jQuery.clone kind of API to clone the Object and move it to your Stack or Queue.
    This way you can ensure object states are maintained separately.

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

Sidebar

Related Questions

I have a collection of an object called Bookmarks which is made up of
Hey. I have an object that has a string property called BackgroundColor. This string
I have a c# object with a property called Gender which is declared as
I have a property called IsSecureConnection that is part of my object's interface. This
I have an object of the type System.Drawing.Image and want to make every pixel
i have an object called 'item'. it has a property called 'type' when i
I have an object called Result<T> that has a constructor which accepts an argument
I have an object called Person that has the following properties: int id; Name
So I have an object called FixedSizeList that does not have a parameterless constructor.
Say I have an object called data which contains a variety of information. Let'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.