JS Built-ins
← Date54 / 120
DategetSecondsbeginner

getSeconds() β€” result is a number

πŸ“– Usage Example
const d = new Date(2024, 0, 15, 12, 30, 45)
d.getSeconds()  // β†’ 45
// returns 0–59

Use getSeconds() to retrieve the seconds component (0–59) of a Date object in local time.

Date.prototype.getSeconds()

getSeconds() returns a number in [0, 59].

Challenge: Verify that typeof new Date(2024, 0, 15, 12, 30, 45).getSeconds() returns 'number'.

πŸ’‘ Hints (1)
  • β€’ getSeconds() always returns a number