1. Mozilla Developer Network (MDN) Web Docs
Date.prototype.setDate(): "The setDate() method of a Date instance changes the day of the month for this date according to local time... If the dayValue is outside of the range of date values for the month
setDate() will update the Date object accordingly." This confirms the rollover behavior essential for the correct answer.
Source: Mozilla
Date.prototype.setDate()
Accessed on [Current Date]
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/GlobalObjects/Date/setDate
2. Mozilla Developer Network (MDN) Web Docs
Date.prototype.getDate(): "The getDate() method of a Date instance returns the day of the month for this date according to local time." This confirms the method used to retrieve the current day number.
Source: Mozilla
Date.prototype.getDate()
Accessed on [Current Date]
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/GlobalObjects/Date/getDate
3. ECMAScript® 2023 Language Specification (ECMA-262
14th edition): The behavior of setDate is formally defined. The specification details the internal SetDate abstract operation
which correctly calculates the final date when the day argument causes the month or year to change.
Source: ECMA International
ECMAScript Language Specification
14th Edition
June 2023
Section 21.4.4.25 Date.prototype.setDate ( date ).