code: function(src, dst) {
      dst = dst || {};
  
      // Remove any properties in destination that were not
      // returned from the source
      forEach(dst, function (value, key) {
          if(!src.hasOwnProperty(key) && key.charAt(0) !== '$') {
              delete dst[key];
          }
      });
  
      for(var key in src) {
  
          if(src.hasOwnProperty(key) && key.charAt(0) !== '$')  {
              // For properties common to both source and destination,
              // check for object references and recurse as needed. Route around
              // arrays to prevent value/order inconsistencies
              if(angular.isObject(src[key]) && !angular.isArray(src[key])) {
                  dst[key] = shallowClearAndCopy(src[key], dst[key]);
              } else {
                  // Not an object, so just overwrite with value from source
                  dst[key] = src[key];
              }
          }
      }
  
      return dst;
  }
docs: Create a shallow copy of an object and clear other fields from the destination https://github.com/angular/angular.js/blob/master/src/ngResource/resource.js#L30