1.0.0 • Published 8 years ago
updateobject v1.0.0
updateObject
Update an object properties, without breaking references.
Usage
updateObject(target, source)
The algorithm modifies the target
object properties in place.
target
: the existing object to updatesource
: the object which properties has to be copied in thetarget
object
Example
var main_data = {
a: {
title: "A"
},
b: {
title: "B"
}
};
var main_data_a = main_data.a;
var main_data_b = main_data.b;
var new_data = {
a: {
title: "Aa"
},
b: {
title: "Bb"
}
};
updateObject(main_data, new_data);
main_data_a // { title: "Aa"}
main_data_b // { title: "Bb"}
1.0.0
8 years ago