To compare two date objects, you can use getTime()
method, which returns the time value in milliseconds.
const date1 = new Date('2024-12-01');
const date2 = new Date('2024-12-01');
console.log(date1.getTime() === date2.getTime()); // true
Tags: basic, JavaScript, date and time
URL: https://www.tiktok.com/@jsmentoring/photo/7455822418272062752