M
mdupris
OK, so I realize JavaScript uses essentially a "by reference" style
within its assignment operator. Thus, in this script:
var dtSrce;
var dtTarget;
dtSrc = new Date();
alert("Src before: " + dtSrc);
dtTarget = dtSrc;
dtTarget.setDate(14);
alert("Src after: " + dtSrc + "\nTarget after: " + dtTarget) ;
the values of dtSrc and dtTarget end up identical. What I'm stumbling
over is how to get around this, that is, how to I create a separate,
independent date object which happens to have the same value (and yes,
presumably other properties) as the first object? Any education here
would be greatly appreciated.
within its assignment operator. Thus, in this script:
var dtSrce;
var dtTarget;
dtSrc = new Date();
alert("Src before: " + dtSrc);
dtTarget = dtSrc;
dtTarget.setDate(14);
alert("Src after: " + dtSrc + "\nTarget after: " + dtTarget) ;
the values of dtSrc and dtTarget end up identical. What I'm stumbling
over is how to get around this, that is, how to I create a separate,
independent date object which happens to have the same value (and yes,
presumably other properties) as the first object? Any education here
would be greatly appreciated.