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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:32:59+00:00 2026-06-13T10:32:59+00:00

I built an app in early version of knockout and the code looked like:

  • 0

I built an app in early version of knockout and the code looked like:

    var ProductCollection = function(products, metadata) {
        var self = this;
        this.allProducts = products;
        this.activeProducts = ko.observableArray(products);

Then if I filtered out items from the activeProduct array like:

    this.activeProducts.remove(function(item) { //some code })

I was able to reset activeProducts to all products by doing something like:

    this.activeProducts(this.allProducts);

But now it seems like if I do the remove function above its removing products from this.allProducts also… Is the products i’m passing in and setting linking to the same reference or something? I don’t get why this would happen now and not before. I’d like to be able to keep this.activeProducts and this.allProducts as separate arrays.

  • 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-13T10:33:00+00:00Added an answer on June 13, 2026 at 10:33 am

    As your experimentation has shown, ko.observableArray() simply wraps the underlying array. It doesn’t clone the underlying array and then make a new instance.

    Here’s more from the the Knockout documentation:

    An observableArray tracks which objects are in the array…

    An observableArray just tracks which objects it holds, and notifies listeners when objects are added or removed…

    …You can get the underlying JavaScript array by invoking the observableArray as a function with no parameters…

    Technically you can use any of the native JavaScript array functions to operate on that underlying array…


    // Thanks @RP Niemeyer
    this.activeProducts = ko.observableArray(products.slice(0));
    
    // Deep copy with jQuery
    this.activeProducts = ko.observableArray(jQuery.extend(true, {}, products));
    

    Also, if you’re really curious, there’s an entire question dedicated to Javascript cloning over here.

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

Sidebar

Related Questions

A Web App built with Google Apps Script has a Url link like this:
I built my app, it looked fine in the interface builder, it looked fine
I have an app built on Express.js and I'd like to test the file
I have an app built in CI and I would like that sessions don't
I built an app on cocos2d version 0.8 and now can not find an
I've built app using wmp.dll which is Windows System File in my XP machine.
I built my app using Grails 2.0.4 and tested it in Jetty. In Jetty
I built a blackberry app with Phonegap. Phonegap build website built my app and
I´ve built an app for the iOs in flash. I successfully generated de .ipa
We built an app for a client some time back, signed it with our

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.