JS Built-ins
← Date25 / 120
DategetFullYearintermediate

getFullYear() β€” after setFullYear()

πŸ“– Usage Example
const d = new Date(2024, 0, 15)
d.getFullYear()  // β†’ 2024

Use getFullYear() to retrieve the four-digit year of a Date object in local time.

Date.prototype.getFullYear()

After calling setFullYear(), getFullYear() reflects the updated year.

Challenge: Verify that after setFullYear(2030), getFullYear() returns 2030.

πŸ’‘ Hints (1)
  • β€’ setFullYear() mutates the Date in place; getFullYear() then returns the updated year