var currrentdate = lastDate;
currrentdate = new Date(currrentdate.setDate(currrentdate.getDate() + diffDays));
Here i changed only currentdate value. but lastDate value also changed when i set date for currentdate why?
var currrentdate = lastDate;
currrentdate = new Date(currrentdate.setDate(currrentdate.getDate() + diffDays));
Here i changed only currentdate value. but lastDate value also changed when i set date for currentdate why?
Can you replace var currrentdate = lastDate;
this line with var currrentdate = new Date(lastDate);
.
This should work fine.
Please reply if you need anything else.
Fundamentals of Javascript language - reference type vs value type:
Primitive value vs Reference value
Read that and search in google "reference type vs value type in javascript" in browser - you will find lots of interesting information.