DEV Community

Discussion on: Oh Javascript... 🙄

Collapse
 
kspeakman profile image
Kasey Speakman

You are right, it is a relatively minor tripping hazard. JS has lots of those. But it is one that I tripped over recently. :)

The unexpected behavior is that simply changing the separator character changes the result. Most of the time, users will consider common date separators like hyphen and slash interchangeable. Now I have to either write extra code to remediate that expectation or confuse users when it does not work as expected (bad UX, and a non-option).

Also, my locale does not use that date notation. I would be surprised if JS Date parsing took locale into consideration.