I have a json object containing information about a person, and I want to update the data using jQuery
extend function, the problem is that the child gets rewritten.
example:
var dadThen = {
name: "Adam",
age: 35,
child:{
name: "Ben",
age: 10
}
}
// dad now
var dadNow = {
age: 36,
child: {
age: 11
}
}
var newData = $.extend({}, dadThen, dadNow);
// The child name gets removed
// newData.child.name is undefined
How to fix this?