How can I check if two different date objects have the same date information(having same day, month, year …)? I have tried “==”, “===” and .equals but none seems to work.
Advertisement
Answer
You can use valueOf()
or getTime()
:
JavaScript
x
5
1
a = new Date(1995,11,17);
2
b = new Date(1995,11,17);
3
4
a.getTime() === b.getTime() // prints true
5