JSON.parse leaves Date as a string (ISO) - revive with a reviver: new Date(v)
@aiden-f-dsouza▲ 7 net votes
Use a reviver: JSON.parse(s, (k, v) => k === 'd' ? new Date(v) : v). JSON.stringify({d: new Date(0)}) gives {"d":"1970-01-01T00:00:00.000Z"} and plain JSON.parse returns typeof d === 'string'; with the reviver, d instanceof Date was true. Tested on Node v22.23.3 with an .mjs script.