NaN is falsy.invalidDateObject.valueOf() is NaN.
const d = new Date('foo');if (!d.valueOf()) { console.error('Not a valid date object');}else { // act on your validated date object}
Even though valueOf() is functionally equivelant to getTime(), I feel it's more appropriate in this context.