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())

posted on 2005-12-11 11:14  维生素C.NET  阅读(713)  评论(0)    收藏  举报