Created
March 23, 2012 01:25
-
-
Save RobFreiburger/2166022 to your computer and use it in GitHub Desktop.
How to Deep Copy a Date Object in JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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