I am currently working on implementing a filter method in a Vue component.
Here is the filter method I am trying to use:
filterHotels:function(){
var thisHotels = this.hotelRoomArr;
console.log(this.hotelRoomArr['107572']['rooms'])
//this outputs:
{__ob__: Observer}
3: (...)
__ob__: Observer {value: {…}, dep: Dep, vmCount: 0}
get 3: ƒ reactiveGetter()
set 3: ƒ reactiveSetter(newVal)
__proto__: Object
thisHotels['107572']['rooms'] = {};
console.log(this.hotelRoomArr['107572']['rooms']);
//this outputs:
{__ob__: Observer}
__ob__: Observer {value: {…}, dep: Dep, vmCount: 0}
__proto__: Object
}
Upon inspecting the code above:
Despite setting the rooms property of thisHotels to an empty object, it seems that the rooms property of this.hotelRoomArr also gets modified.
Logically speaking, the rooms property of this.hotelRoomArr should not be affected by this change.
What can I do to prevent changes to this.hotelRoomArr when modifying rooms?