Date is a reference type in JavaScript
If you try this:
(new Date(2000, 0, 1)) == (new Date(2000, 0, 1))
you may be surprised to learn that it is actually false, because they are different object references, even if the values are the same. If you want to check equality of two dates, you need to compare the values instead of the Date objects:
(new Date(2000, 0, 1)).valueOf() == (new Date(2000, 0, 1).valueOf())
Hope this helps.