logoalt Hacker News

WorldMakertoday at 1:58 AM0 repliesview on HN

The fun trick is that Invalid Date is still a Date:

    > let invalid = new Date('not a date')
    > invalid
    Invalid Date
    > invalid instanceof Date
    true
You were half-correct on expecting NaN, it's the low level storage of Invalid Date:

    > invalid.getTime()
    NaN
Invalid Date is just a Date with the "Unix epoch timestamp" of NaN. It also follows NaN comparison logic:

    > invalid === new Date(NaN)
    false
It's an interesting curio directly related to NaN.