this post was submitted on 06 Nov 2023
1 points (100.0% liked)
Programmer Humor
35244 readers
25 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
You want to create the date "31st February", but it's JavaScript that's cursed?
Write a less side-effecty function.
The point is that this scenario exists in Js in the first place. It's a completely unnecessary rake left around for people to step on. Also, the function isn't side effecty since it doesn't make implicit references outside its scope. The fact that the date is mutable is an internal concern there. You could just as easily do
The problem here isn't with side effects, but with having to know that you want to set your date to first day to get the next month reliably.