![Check if a date is before another date](https://javascriptsource.com/wp-content/uploads/2021/08/Check-if-a-date-is-before-another-date-702x526.jpg)
Use the less than operator (<
) to check if the first date comes before the second one.
const isBeforeDate = (dateA, dateB) => dateA < dateB;
// Example
isBeforeDate(new Date(2010, 10, 20), new Date(2010, 10, 21)); // true
Source
https://www.30secondsofcode.org/js/s/is-before-date