JS Built-ins
← Date40 / 120
DategetDaybeginner

getDay() β€” result is a number

πŸ“– Usage Example
const d = new Date(2024, 0, 15)  // Monday
d.getDay()  // β†’ 1
// 0=Sun, 1=Mon, …, 6=Sat

Use getDay() to retrieve the day of the week (0 = Sunday through 6 = Saturday) in local time.

Date.prototype.getDay()

getDay() returns a primitive number.

Challenge: Verify that typeof new Date(2024, 0, 15).getDay() returns 'number'.

πŸ’‘ Hints (1)
  • β€’ getDay() always returns a number β€” specifically an integer in [0, 6]