JS Built-ins
← Date13 / 120
Dateparsebeginner

Date.parse() β€” returns a number

πŸ“– Usage Example
Date.parse('2024-01-15T00:00:00.000Z')  // β†’ 1705276800000
Date.parse('invalid')  // β†’ NaN

Use Date.parse() to convert a date string into a millisecond timestamp, or detect invalid strings by checking for NaN.

Date.parse()

Date.parse() always returns a primitive number (or NaN, which is also of type 'number').

Challenge: Verify that typeof Date.parse('2024-01-15') returns 'number'.

πŸ’‘ Hints (1)
  • β€’ Both valid and invalid parse results are of type "number" (NaN is typeof "number" too)