JS Built-ins
← Date81 / 120
DatesetFullYearbeginner

setFullYear() β€” set to 2025

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

Use setFullYear() to mutate the year of a Date object in place; the month and day remain unchanged.

Date.prototype.setFullYear()

Mutates the Date in place, setting the year. Returns the new timestamp as a number.

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

πŸ’‘ Hints (1)
  • β€’ setFullYear() mutates the Date object in place β€” it does not create a new Date