30
you are viewing a single comment's thread
view the rest of the comments
[-] yogthos@lemmy.ml -5 points 1 year ago

But that isn’t what it does. From the original post:

The problem would be the same if you were just doing an offset from the current month. You're now nitpicking the example while ignoring the point being made. Perhaps this version will help clarify the problem for you better:

function getLastMonthName() {
  const date = new Date();
  date.setMonth(date.getMonth() - 1);
  return date.toLocaleString([], { month: 'long' });
}

No, it wouldn’t. As I have said before, testing for unexpected return values is just as effective as testing for errors, that is, not very with the function originally presented under sensible assumptions.

I'll repeat this again, the failure case is not obvious and you can easily miss the test for it. Throwing an error makes it much easier to identify that there is a problem, and that's why APIs in sane languages such as Java behave this way.

This claim of intent, not present in the original post, is an example of you changing your story over time.

Nobody is changing the story over time, you're just incapable of acknowledging being wrong.

Given that I have agreed and commiserated, and neither of us can change JavaScript, there is nothing to be gained from pursuing this complaint.

Which is precisely why I posted this on Programmer Humor. Js is a garbage language, and it's obviously beyond fixing, but I can laugh at it.

this post was submitted on 06 Nov 2023
30 points (68.3% liked)

Programmer Humor

32745 readers
204 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS