Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
const json = '{"name":"Alice","createdAt":"2024-06-15T10:30:00.000Z"}'; // Without reviver: createdAt is a plain string const raw = JSON.parse(json); console.log(raw.createdAt instanceof Date); // false // With reviver: convert ISO strings to Date objects const parsed = JSON.parse(json, (key, value) => { if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}T/.test(value)) { return new Date(value); } return value; }); console.log(parsed.createdAt instanceof Date); // true
Result
Open