In code below, I don't want the string not_a_date to be whitelisted as a proper date, but rather as NaN or invalid date. but Date.parse returns a proper epoch value.
not_a_date = 'https://www.example.com/2021/03/03'
Date.parse(not_a_date)
// Expected: NaN
// Result: 1614709800000
Date.parse for other cases such as 2020.01.01, 01/10/2020Date.parse is still largely dependant on the browser you're using; your code DOES return NaN in Firefox v94 for example. You'll likely have to write your own parsing function before passing it to Date.parse().