Javascript logo

The Date is an object in JavaScript and TypeScript. When you have some spare time, try to compare 2 objects, you will find a lot of interesting things 🙂 Obviously, you need to compare not object, but their properties.

But if you want to compare 2 Dates, you can easily convert then to numbers with getTime() method.

In the example below I compare the existing date with the current moment.

const isStarted: boolean = (new Date(eventDate).getTime() < (new Date().getTime()))