Example 1 — Set the Day of the Month
Change the local day, then read it back with getDate().
const event = new Date("August 19, 1975 23:15:30");
event.setDate(24);
console.log(event.getDate()); // 24 How It Works
- Start with a date. August 19, 1975 is the baseline.
- Write the day.
setDate(24)stores day24. - Read it back.
getDate()returns24. - Mutates. The same
eventobject is updated in place.

