![Check if a date is the same as another date](https://javascriptsource.com/wp-content/uploads/2021/12/Check-if-a-date-is-the-same-as-another-date-702x526.jpg)
Use Date.prototype.toISOString()
and strict equality checking (===
) to check if the first date is the same as the second one.
const isSameDate = (dateA, dateB) =>
dateA.toISOString() === dateB.toISOString();
// EXAMPLE
isSameDate(new Date(2010, 10, 20), new Date(2010, 10, 20)); // true