What’s the best (clearest, shortest, fastest, etc.) way to determine whether a Date object is equal to, say, July 4, 2012?
For example, this works but is rather verbose:
if (date.getFullYear() === 2012 && date.getMonth() + 1 === 7 && date.getDate() === 4)
Is there a more elegant solution?
(In my actual scenario, server-side code will be plugging in the specific date to test against. Also, the date comes from a jQuery UI datepicker and so will have a time component of 00:00:00.)
Construct a new date and compare the results of
getTime: