{"action":"created","issue":{"url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4069","labels_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4069/labels{/name}","comments_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4069/comments","events_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4069/events","html_url":"https://github.com/jashkenas/coffeescript/pull/4069","id":102563476,"number":4069,"title":"Implement ES2015-like destructuring defaults","user":{"login":"lydell","id":2142817,"avatar_url":"https://avatars.githubusercontent.com/u/2142817?v=3","gravatar_id":"","url":"https://api.github.com/users/lydell","html_url":"https://github.com/lydell","followers_url":"https://api.github.com/users/lydell/followers","following_url":"https://api.github.com/users/lydell/following{/other_user}","gists_url":"https://api.github.com/users/lydell/gists{/gist_id}","starred_url":"https://api.github.com/users/lydell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lydell/subscriptions","organizations_url":"https://api.github.com/users/lydell/orgs","repos_url":"https://api.github.com/users/lydell/repos","events_url":"https://api.github.com/users/lydell/events{/privacy}","received_events_url":"https://api.github.com/users/lydell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-08-22T19:58:03Z","updated_at":"2015-08-27T21:50:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/jashkenas/coffeescript/pulls/4069","html_url":"https://github.com/jashkenas/coffeescript/pull/4069","diff_url":"https://github.com/jashkenas/coffeescript/pull/4069.diff","patch_url":"https://github.com/jashkenas/coffeescript/pull/4069.patch"},"body":"This let's you do things like:\r\n\r\n    fullName = ({first = 'John', last = 'Doe'}) -> \"#{first} #{last}\"\r\n\r\nNote: CoffeeScrits treats `undefined` and `null` the same, and that's true in\r\nthe case of destructuring defaults as well, as opposed to ES2015 which only uses\r\nthe default value if the target is `undefined`. A similar ES2015 difference\r\nalready exists for function parameter defaults. It is important for CoffeeScript\r\nto be consistent with itself.\r\n\r\n    fullName2 = (first = 'John', last = 'Doe') -> \"#{first} #{last}\"\r\n    assert fullName('Bob', null) is fullName2(first: 'Bob', last: null)\r\n\r\nFixes #1558, #3288 and #4005."},"comment":{"url":"https://api.github.com/repos/jashkenas/coffeescript/issues/comments/135565531","html_url":"https://github.com/jashkenas/coffeescript/pull/4069#issuecomment-135565531","issue_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4069","id":135565531,"user":{"login":"jashkenas","id":4732,"avatar_url":"https://avatars.githubusercontent.com/u/4732?v=3","gravatar_id":"","url":"https://api.github.com/users/jashkenas","html_url":"https://github.com/jashkenas","followers_url":"https://api.github.com/users/jashkenas/followers","following_url":"https://api.github.com/users/jashkenas/following{/other_user}","gists_url":"https://api.github.com/users/jashkenas/gists{/gist_id}","starred_url":"https://api.github.com/users/jashkenas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jashkenas/subscriptions","organizations_url":"https://api.github.com/users/jashkenas/orgs","repos_url":"https://api.github.com/users/jashkenas/repos","events_url":"https://api.github.com/users/jashkenas/events{/privacy}","received_events_url":"https://api.github.com/users/jashkenas/received_events","type":"User","site_admin":false},"created_at":"2015-08-27T21:50:28Z","updated_at":"2015-08-27T21:50:28Z","body":"Pretty cool how (relatively) simple this is to implement.\r\n\r\nFor the record — historically, I haven't been in favor of adding the complexity of defaults to the destructuring syntax, which is already one of the most complex parts of the language.\r\n\r\nBut if JavaScript is doing it, okay."}}