object assign only existing properties code example
Example: typescript add property if not exist, merge if it exists
Object.keys(obj2).forEach(function(key) {
if (key in obj1) { // or obj1.hasOwnProperty(key)
obj1[key] = obj2[key];
}
});