Can anyone explain to me why the month is set incorrectly in "defaultDate.setDate(d.getDate());" in the code below? I know that JS runs months from a 0 index, however I would have assumed that setDate() would take care of any discrepencies.
<script>
var defaultDate = new Date();
window.alert(defaultDate);
function testfunction(){
var d=new Date();
window.alert(d);
d.setDate(d.getDate()-10);
window.alert(d);
defaultDate.setDate(d.getDate());
window.alert(defaultDate);
}
testfunction();
</script>