I have an issue related to objects in javascript. I actually need to put the value of my original variable value in a temporary variable that I can refer later the perform a business logic.
The issue is that whenever I modify the original variable value the temporary gets updated too
Putting the value in the temporary variable
Here this.startingTime = 10:00
and this.endingTime = 12:00
this.startingTime = new Date(this.selectedAvailability.scheduleDate + ' ' + this.selectedAvailability.startTime);
this.endingTime = new Date(this.selectedAvailability.scheduleDate + ' ' + this.selectedAvailability.endTime);
this.tempStartTime = this.startingTime;
this.tempEndingTime = this.endingTime;
Updating as follow update the original and the temp
this.endingTime = 11:30
this.tempEndingTime = 11:30 (The temp variable gets updated also, but here what I want is the temp to stay 12:00)
this.endingTime.setMinutes(this.endingTime.getMinutes() - 30);