How would you approach serializing and deserializing non-JSON-compatible data types like Dates or Functions in JavaScript?

Free for the first 3 answer contributors

Interview question asked to Frontend Engineers interviewing at FromSoftware, Amazon, Riot Games and others: How would you approach serializing and deserializing non-JSON-compatible data types like Dates or Functions in JavaScript?.