I am trying to copy a date property from an object and modify it as shown below, yet each time I try to modify the 'copied' date property, I end up having the object date property modified as well. So was wondering is there a way I can modify the copied date without affecting the date property in the original object? Any help with sample code is highly appreciated. Thanks
A. Object (saved in a taskObject var)
{ name: 'test',
endDate: Thu Apr 13 2017 18:46:02 GMT+0200 (EET)
}
B. Code:
let currentTaskEndDate = taskObject.endDate; //where taskObject is the object above
//The following line will result in taskObject.endDate to be updated by new date!
currentTaskEndDate.setDate(currentTaskEndDate.getDate() + Number(5));