Comment

Comment by Prefinem

If you are writing a reviver, what difference is it to instead write a deep clone function?

JSON.parse(JSON.stringify(obj)) !== deepClone(obj)

EDIT: Also, how can you determine if the string should be a date, or a string? Sure, if it fits, you can always convert it to a Date, but if your first object is coming from something that sends ISO Dates as strings and you used JSON.parse with a reviver, you would get a different object.

parent Prefinem 8 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton