{"action":"created","issue":{"url":"https://api.github.com/repos/lodash/lodash/issues/1248","labels_url":"https://api.github.com/repos/lodash/lodash/issues/1248/labels{/name}","comments_url":"https://api.github.com/repos/lodash/lodash/issues/1248/comments","events_url":"https://api.github.com/repos/lodash/lodash/issues/1248/events","html_url":"https://github.com/lodash/lodash/issues/1248","id":82521946,"number":1248,"title":"Reverse Deep Merge","user":{"login":"kentcdodds","id":1500684,"avatar_url":"https://avatars.githubusercontent.com/u/1500684?v=3","gravatar_id":"","url":"https://api.github.com/users/kentcdodds","html_url":"https://github.com/kentcdodds","followers_url":"https://api.github.com/users/kentcdodds/followers","following_url":"https://api.github.com/users/kentcdodds/following{/other_user}","gists_url":"https://api.github.com/users/kentcdodds/gists{/gist_id}","starred_url":"https://api.github.com/users/kentcdodds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kentcdodds/subscriptions","organizations_url":"https://api.github.com/users/kentcdodds/orgs","repos_url":"https://api.github.com/users/kentcdodds/repos","events_url":"https://api.github.com/users/kentcdodds/events{/privacy}","received_events_url":"https://api.github.com/users/kentcdodds/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-29T17:50:50Z","updated_at":"2015-05-29T17:54:59Z","closed_at":null,"body":"I may just not know what the name for this is, but in my project I have this function that essentially works like `merge` but instead of the \"rest\" parameters overriding the destination object, it just fills in `undefined values. Something like this:\r\n\r\n```javascript\r\nvar x = {foo: 'bar'};\r\nvar y = {foo: 'baz', foobar: 'eggs'};\r\n_.merge(x, y);\r\n_.eq(x, {foo: 'bar', foobar: 'eggs'}); // <-- true\r\n```"},"comment":{"url":"https://api.github.com/repos/lodash/lodash/issues/comments/106888108","html_url":"https://github.com/lodash/lodash/issues/1248#issuecomment-106888108","issue_url":"https://api.github.com/repos/lodash/lodash/issues/1248","id":106888108,"user":{"login":"kentcdodds","id":1500684,"avatar_url":"https://avatars.githubusercontent.com/u/1500684?v=3","gravatar_id":"","url":"https://api.github.com/users/kentcdodds","html_url":"https://github.com/kentcdodds","followers_url":"https://api.github.com/users/kentcdodds/followers","following_url":"https://api.github.com/users/kentcdodds/following{/other_user}","gists_url":"https://api.github.com/users/kentcdodds/gists{/gist_id}","starred_url":"https://api.github.com/users/kentcdodds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kentcdodds/subscriptions","organizations_url":"https://api.github.com/users/kentcdodds/orgs","repos_url":"https://api.github.com/users/kentcdodds/repos","events_url":"https://api.github.com/users/kentcdodds/events{/privacy}","received_events_url":"https://api.github.com/users/kentcdodds/received_events","type":"User","site_admin":false},"created_at":"2015-05-29T17:54:59Z","updated_at":"2015-05-29T17:54:59Z","body":"If this is useful, this does it for me:\r\n\r\n```javascript\r\nvar x = {foo: 'bar'};\r\nvar y = {foo: 'baz', foobar: 'eggs'};\r\nreverseDeepMerge(x, y);\r\n_.eq(x, {foo: 'bar', foobar: 'eggs'}); // <-- evaluates to true\r\n\r\nfunction reverseDeepMerge(dest) {\r\n  _.each(arguments, function(src, index) {\r\n    if (!index) {\r\n      return;\r\n    }\r\n    _.each(src, function(val, prop) {\r\n      if (_.isUndefined(dest[prop])) {\r\n        dest[prop] = _.clone(val);\r\n      } else if (objAndSameType(dest[prop], val)) {\r\n        reverseDeepMerge(dest[prop], val);\r\n      }\r\n    });\r\n  });\r\n}\r\n\r\nfunction objAndSameType(obj1, obj2) {\r\n  return _.isObject(obj1) && _.isObject(obj2) &&\r\n    Object.getPrototypeOf(obj1) === Object.getPrototypeOf(obj2);\r\n}\r\n```"}}