https://jsfiddle.net/meeky333/zhgybqou/8/
In my jsfiddle I have a 1st, 2nd and 3rd date. I have assigned 1 = new Date()
and then assigned 2 = 1
and then 3 = 2
, except I set the hours of 2 using .setHours()
.
I understand that .setHours()
will not only return the date in an int form. But it will update the object it came from... But it has come from mySecondDate
. So why is myFirstDate
being changed also?
How do I make myThirdDate
stay the same but keep the value of myFirstDate
the same as it was.
NOTE: mySecondDate
is just a throw away variable, It was just for illustration purposes.