Tech article
addDays() Mutated a Date Three Components Away From Where I Called It
Community description: A date utility that calls .setDate() and returns the same object looks pure. It isn't — Date is mutable, so the caller and everyone else holding that reference get changed out from under them. Temporal, now shipping in real browsers, fixes it by making dates immutable.
Dev.to | Sep 12, 2026 | Parsa Jiravand
Automated excerpt
Takes a date, takes a number, returns a date. Look before you scroll nextOccurrence takes a Date object and returns one. It rendered the mutated object perfectly.
Selected automatically from source text; not independently written or fact-checked. Read the original for full context.