JS Built-ins
Datebeginner

Date Constructor β€” year, month, day args

πŸ“– Usage Example
const d1 = new Date()
const d2 = new Date('2024-01-15')
const d3 = new Date(2024, 0, 15)  // β†’ Jan 15 2024
d3 instanceof Date  // β†’ true

Use new Date() to create a Date object from the current time, a timestamp, a date string, or explicit year/month/day arguments.

Date Constructor

new Date(year, month, day) creates a local-time Date. Month is 0-indexed (0 = January, 11 = December).

Challenge: Verify that new Date(2024, 0, 15).getMonth() returns 0 (January).

πŸ’‘ Hints (1)
  • β€’ Month index starts at 0: January=0, February=1, …, December=11