- cross-posted to:
- programmer_humor@programming.dev
- programming@programming.dev
- cross-posted to:
- programmer_humor@programming.dev
- programming@programming.dev
cross-posted from: https://programming.dev/post/33754840
new Date(“wtf”)
This quiz was stressful. Like, there were so many times when I knew I was being cued up for a trick question, but I still fell for it.
Best laugh I’ve had in a while. That is some grade-A jank.
In the process of being replaced.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal
JavaScript has had the
Date
object for handling date and time since its first days. However, theDate
API is based on the poorly designedjava.util.Date
class from Java, which was replaced in the early 2010s; but, because of JavaScript’s goal of backward compatibility,Date
sticks around in the language.Damn, I thought you meant JavaScript itself was being replaced.
Ok, I get that the Date API is problematic, but I wouldn’t expect anything meaningfull from
new Date("not a date").getTime()
anyway. Why would you in the first place?Parsing user input? Nonsense data coming from an API?
If you’re expecting shit data then you’d have unit tests for those cases so you’d know what to expect.