Well consider this bit of code:
var d1 = new Date(); var d2 = d1; d2.setDate(d2.getDate()+1); alert(d1 + "\n" + d2);
Even though I call setDate() on d2 , d1 also increments. I understand this because d1 is assigned to d2 by reference. My question is: how do I NOT do this, so that .setDate() only applies to d2 ?
source share