Skip to content

Instantly share code, notes, and snippets.

@RobFreiburger
Created March 23, 2012 01:25
Show Gist options
  • Save RobFreiburger/2166022 to your computer and use it in GitHub Desktop.
Save RobFreiburger/2166022 to your computer and use it in GitHub Desktop.
How to Deep Copy a Date Object in JavaScript
// What works
var original = new Date();
var copy = new Date(original);
// What doesn't work
copy = original; // It should work, but it passes by reference so changes to copy also affect original
copy = jQuery.extend(true, {}, original); // Passes a useless object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment