For example:
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 and date2 are both objects, and their types are reference types, so if you need to compare them, you need to compare their literal values instead of simply using == to compare.
If you want to compare whether two dates are equal, you can write
var date1 = new Date("2013-11-29");
var date2 = new Date("2013-11-29");
console.log(date1.getTime() == date2.getTime()); //true
Using the getTime() method, you can return the value corresponding to the date, and then compare it.
Actually, there is another way to compare dates.
var date1 = new Date("2013-11-29 ");
var date2 = new Date("2013-11-29");
console.log(date1 - date2 == 0); //true
is used here Subtract date2 from date1 to get the time difference between them. If it is 0, it must be equal.