How to compare dates without time in JavaScript?

10 months ago
Anonymous $rc1z7tsipX

let date1 = new Date("2024-01-29T03:34:48.000Z"); // Tue Jan 29 2024 03:34:48 GMT+0000

let date2 = new Date("2024-01-29T15:00:00.000Z"); // Tue Jan 29 2024 15:00:00 GMT+0000

let date1String = date1.toDateString(); // "Tue Jan 29 2024"

let date2String = date2.toDateString(); // "Tue Jan 29 2024"

console.log(date1String === date2String); // Output: true

console.log(date1String < date2String); // Output: false

console.log(date1String > date2String); // Output: false