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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:34:53+00:00 2026-06-17T23:34:53+00:00

I have declared 2 observable arrays as following in my code self.versionDataByProduct = ko.observableArray([]);

  • 0

I have declared 2 observable arrays as following in my code

self.versionDataByProduct = ko.observableArray([]);
self.copiedSavedVersionData = ko.observableArray([]);

When i save data i copy all value from self.versionDataByProduct into self.copiedSavedVersionData like below

 self.copiedSavedVersionData(self.versionDataByProduct());

Then i try to compare 2 observable array on button event called compareArray like below

 this.compareArray = function () {
        debugger;
        var results = [];
        var differences = ko.utils.compareArrays(self.versionDataByProduct(), self.copiedSavedVersionData());
        ko.utils.arrayForEach(differences, function (difference) {
            if (difference.status === "deleted") {
                results.push(difference.value);
            }
        });
        return results;
    };

But this doesnt work. Because after i copy one observable array to other and do some modification in observable array then it automatically updates other. I dont want that. I want my observable array self.copiedSavedVersionData to remain as is after it is copied. How can i achieve it? I am just doing it track if i have done any changes. If array is changed then i will enable button in my code. Currently i dont know how do i go about dirty tracking so found this alternative but not working. Please help.

  • 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-17T23:34:55+00:00Added an answer on June 17, 2026 at 11:34 pm

    You can use slice function for this:

     self.copiedSavedVersionData(self.versionDataByProduct().slice(0));
    

    In that case ko will clone array.

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

Sidebar

Related Questions

I have declared the following template to make code shorter: template <typename T> void
I have declared int value in my main, and all of the processes has
I have declared the following enum type in which I want the first member
I have declared the following Enum: public enum AfpRecordId { BRG = 0xD3A8C6, ERG
I have declared the following enum : enum periods {one, five, ten, fifteen, thirty};
I have declared the following method: private void mockInvokeDBHandler(Map<String, Object>... rows) { List<Map<String, Object>>
I have declared a manager to the following model, but after doing so, I
I have declared the following interface in Java: public interface ITest { void doStuff();
I have an input text like below: <input type=text style=width: 80% data-bind=value: Note, event:
I have declared some Non-Content data in an Orchard CMS by defining the records

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.