$.extend deep copy and Date
Hi,
I was having some issues with $.extend deep copy.
basically i have something like this.(the actual object was nested so i was using deep copy).
var oldVal = {
time: new Date('Fri Jun 20 16:32:09 UTC+0530 2008')
};
var newVal = {
time: new Date('Fri Jun 20 16:32:40 UTC+0530 2007')
};
var currentVal = $.extend(true, {}, oldVal, newVal); // deep copy the object
after this i expect the currentVal.time to be a date object, however i am getting it as an object (not a date).
I have temporarily worked around this problem by changing the following line (1.2.6 - line 587).
// Recurse if we're merging object values
if ( deep && copy && typeof copy == "object" && !copy.nodeType )
To
// Recurse if we're merging object values. except if its a Date - should we handle RegExp etc..?
if ( deep && copy && typeof copy == "object" && !copy.nodeType && !(copy instanceof Date))
what is the proper way to do this?