Clones the given Date object.

Type signature

(date: Date) => Date

Examples

const date = new new Date(
  "2019-04-24T13:54:33.232Z",
)();
const cloned = clone(date);

cloned !== date &&
  cloned.valueOf() ===
    date.valueOf();
// ⇒ true
Try in REPL

Questions

  • How to clone a Date object?

TypeScript sourceJavaScript source