===) is not recommended for most cases. Equality operators compare the
Date object references, resulting in
false, even if the date values are the same:
const a = new Date(2022, 01, 10); const b = new Date(2022, 01, 10); a === b; // false
const a = new Date(2022, 01, 10); const b = new Date(2022, 01, 10); a.getTime() === b.getTime(); // true
Date.prototype.toLocaleDateString()provided you use the same locale
All of these methods produce consistent results, but we still recommend
Date.prototype.getTime() due to its simplicity.
Written by Angelos Chalaris
If you want to keep in touch, follow me on GitHub.