Managing JS objects while preserving references
Instead of checking each property in the result to see whether it was in the source object, simply delete all of the properties in the destination object and then use angular.extend or Object.assign to copy from the source.

function replaceObj(target, source) {
    Object.keys(target).forEach(function(key) {
        delete target[key];
    });
    Object.assign(target, source);
}


Also, if you do want to check whether a property is in an object, using updates.kasOwnProperty(objKey) is more straightforward than making a separate array of keys and using indexOf.