{"action":"created","issue":{"url":"https://api.github.com/repos/lodash/lodash/issues/3299","repository_url":"https://api.github.com/repos/lodash/lodash","labels_url":"https://api.github.com/repos/lodash/lodash/issues/3299/labels{/name}","comments_url":"https://api.github.com/repos/lodash/lodash/issues/3299/comments","events_url":"https://api.github.com/repos/lodash/lodash/issues/3299/events","html_url":"https://github.com/lodash/lodash/issues/3299","id":247713930,"node_id":"MDU6SXNzdWUyNDc3MTM5MzA=","number":3299,"title":"_.pick() has (possibly) unintended behaviour when picking object properties that are objects","user":{"login":"mcosletjr","id":6072113,"node_id":"MDQ6VXNlcjYwNzIxMTM=","avatar_url":"https://avatars1.githubusercontent.com/u/6072113?v=4","gravatar_id":"","url":"https://api.github.com/users/mcosletjr","html_url":"https://github.com/mcosletjr","followers_url":"https://api.github.com/users/mcosletjr/followers","following_url":"https://api.github.com/users/mcosletjr/following{/other_user}","gists_url":"https://api.github.com/users/mcosletjr/gists{/gist_id}","starred_url":"https://api.github.com/users/mcosletjr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcosletjr/subscriptions","organizations_url":"https://api.github.com/users/mcosletjr/orgs","repos_url":"https://api.github.com/users/mcosletjr/repos","events_url":"https://api.github.com/users/mcosletjr/events{/privacy}","received_events_url":"https://api.github.com/users/mcosletjr/received_events","type":"User","site_admin":false},"labels":[{"id":2763155,"node_id":"MDU6TGFiZWwyNzYzMTU1","url":"https://api.github.com/repos/lodash/lodash/labels/invalid","name":"invalid","color":"e6e6e6","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-08-03T13:53:12Z","updated_at":"2018-12-27T03:33:17Z","closed_at":"2017-08-03T14:05:00Z","author_association":"NONE","body":"I've come across the issue described in the following code snippet:\r\n```js\r\nvar initialObject = {\r\n  data: {\r\n    name: 'spark'\r\n  },\r\n  someOtherValue: 42\r\n};\r\nvar pickedObject = _.pick(initialObject, ['data']);\r\n\r\npickedObject.data.name = 'labs';\r\n\r\nconsole.log(pickedObject.data.name);  // 'labs'\r\nconsole.log(initialObject.data.name);  // 'labs'\r\n```\r\nIt seems that it doesn't return a new `object` but a refference to the initial one (but with the picked properties). It doesn't happen when picking \"`non-object`\" values, for example (having the same `initialObject`):\r\n\r\n```js\r\nvar pickedObject = _.pick(initialObject, ['someOtherValue']);\r\n\r\npickedObject.someOtherValue = 0;\r\nconsole.log(pickedObject.someOtherValue);  // 0\r\nconsole.log(initialObject.someOtherValue);  // 42\r\n```\r\n\r\nI've solved the bug that has bugged me for days (pun intended) by wrapping the `_.pick()` call with the `_.cloneDeep()` to sever the ties between the `objects`.\r\n\r\nI wouldn't have submitted a new issue had the [documentation](https://lodash.com/docs/4.17.4#pick) not stated that it `Returns the new object.` (the same problem applies when using `_.omit()`) \r\n\r\n"},"comment":{"url":"https://api.github.com/repos/lodash/lodash/issues/comments/450065877","html_url":"https://github.com/lodash/lodash/issues/3299#issuecomment-450065877","issue_url":"https://api.github.com/repos/lodash/lodash/issues/3299","id":450065877,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MDA2NTg3Nw==","user":{"login":"lock[bot]","id":33595554,"node_id":"MDM6Qm90MzM1OTU1NTQ=","avatar_url":"https://avatars1.githubusercontent.com/in/6672?v=4","gravatar_id":"","url":"https://api.github.com/users/lock%5Bbot%5D","html_url":"https://github.com/apps/lock","followers_url":"https://api.github.com/users/lock%5Bbot%5D/followers","following_url":"https://api.github.com/users/lock%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/lock%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/lock%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lock%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/lock%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/lock%5Bbot%5D/repos","events_url":"https://api.github.com/users/lock%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/lock%5Bbot%5D/received_events","type":"Bot","site_admin":false},"created_at":"2018-12-27T03:33:17Z","updated_at":"2018-12-27T03:33:17Z","author_association":"NONE","body":"This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.\n"}}
{"actor":{"display_login":"lock"}}