I dont understand why JS is doing like this. I have declared a class calendar which has an js object as property this.calendar
class SweetCalendar{
constructor(){
this.i_weeknumber = 46;
this.getCalendar();
this.filterCalender();
}
filterCalender(){
var a = this.calendar
for(var i in a){
for(var j in a[i]){
if(a[i][j]["Weeknumber"] != String(this.i_weeknumber)){
delete a[i][j];
}
}
this.calendar_week
}
With the function filterCalendar i want to create a new object which is a subset of the this.calendar property. The function works as designed but this.calendar has now the same values like this.calendar_week. I dont understand why js is doing like this. I copied the object to the variable a so why is this.calender edited by the function filterCalendar?