let cities = [{ "name" : "SF", "id" : 4, "population" : 10, favorite: false}, { "name" : "NY", "id" : 5, "population" : 20, favorite: false}, { "name" : "DC", "id" : 6, "population" : 30, favorite: false}
I have an array and and lets say if a user applies a filter based on the population i can filter the array by using filter method, but it gives me an other array with filtered data. In filtered array user can favorite the city and when user removes the filter i need to show the full list of cities with the favorite indicator. Problem is filtered array is a separate array and the full array doesn't know if a property was changed on the filtered array. Is there any easier way handle all this? Can i filter the main array instead of creating another one?
favoriteproperty will show in both arrays, otherwise you need to update your underlying data model and refresh the unfiltered array from that