I have a filter method (itemsWithFilter) to filter my items object and write the results in itemsResult
this works for the first time but it seems that my function autmatically updated the items object too. Even so I write the results in itemsResult only.
Does anyone know why and how I can prevent it ? That itemsWithFilter methods returns the results to itemsResult only
Here is the Fiddle link: https://jsfiddle.net/afdz3yLt/1/
Here is my itemsWithFilter function
itemsWithFilter: function(filter) {
var items = this.items.data;
var result = {}
console.log("Run itemsWithFilter")
Object.keys(items).forEach(key => {
const item = items[key]
console.log(`filter: ${filter}: check item ${item.id} with category id: ${item.category.id}`)
if (item.category.id == filter) {
result[key] = item
}
})
this.itemsResult.data = result
}