-1
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?

Malathi
  • 43
  • 7

2 Answers2

1

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.

Gopal M
  • 34
  • 4
0

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.

azrahel
  • 1,143
  • 2
  • 13
  • 31