$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · medium · #198

Which fix removes the bug?

const copy = JSON.parse(JSON.stringify(event));
console.log(copy.date.getTime());
  1. Revive the date explicitly
  2. Use Object.assign instead
  3. Spread the object first
  4. Call toJSON() before
JSON has no date type, so the round trip turns the Date into a string with no getTime method.
Play Problem Solving ▸