For example:
Copy Code code as follows:
var date1 = new Date ("2013-11-29");
var date2 = new Date ("2013-11-29");
Console.log (date1 = = Date2); False
Here, Date1 and Date2 look the same, but running date1 = = Date2 returns FALSE. This is because Date1, Date2 are objects, types are reference types, so if you need to compare them, you need to compare their literal values instead of simply using = = to compare them.
If you want to compare two date equality, you can write this
Copy Code code as follows:
var date1 = new Date ("2013-11-29");
var date2 = new Date ("2013-11-29");
Console.log (date1.gettime () = = Date2.gettime ()); True
With the GetTime () method, you can return the value of the date, and then compare it.
In fact, there is also a way to compare dates.
Copy Code code as follows:
var date1 = new Date ("2013-11-29");
var date2 = new Date ("2013-11-29");
Console.log (date1-date2 = 0); True
Here with Date1 minus Date2, that is, you can get the time difference between them, if 0, then it must be equal.