{"action":"created","issue":{"url":"https://api.github.com/repos/getify/You-Dont-Know-JS/issues/513","labels_url":"https://api.github.com/repos/getify/You-Dont-Know-JS/issues/513/labels{/name}","comments_url":"https://api.github.com/repos/getify/You-Dont-Know-JS/issues/513/comments","events_url":"https://api.github.com/repos/getify/You-Dont-Know-JS/issues/513/events","html_url":"https://github.com/getify/You-Dont-Know-JS/issues/513","id":100467918,"number":513,"title":"Confusing contrast between `bind(..)` and fat arrow functions","user":{"login":"IanVS","id":4616705,"avatar_url":"https://avatars.githubusercontent.com/u/4616705?v=3","gravatar_id":"","url":"https://api.github.com/users/IanVS","html_url":"https://github.com/IanVS","followers_url":"https://api.github.com/users/IanVS/followers","following_url":"https://api.github.com/users/IanVS/following{/other_user}","gists_url":"https://api.github.com/users/IanVS/gists{/gist_id}","starred_url":"https://api.github.com/users/IanVS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IanVS/subscriptions","organizations_url":"https://api.github.com/users/IanVS/orgs","repos_url":"https://api.github.com/users/IanVS/repos","events_url":"https://api.github.com/users/IanVS/events{/privacy}","received_events_url":"https://api.github.com/users/IanVS/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-12T05:12:28Z","updated_at":"2015-08-12T13:21:24Z","closed_at":null,"body":"I'm struggling to wrap my head around how arrow functions are so much different from `bind(..)`, as explained in [Lexical `this`](https://github.com/getify/You-Dont-Know-JS/blob/master/this%20%26%20object%20prototypes/ch2.md#lexical-this).  Is it not the case that these two examples are identical?\r\n\r\n```javascript\r\nfunction foo() {\r\n    // return an arrow function\r\n    return (a) => {\r\n        // `this` here is lexically adopted from `foo()`\r\n        console.log( this.a );\r\n    };\r\n}\r\n```\r\n\r\nand \r\n\r\n\r\n```javascript\r\nfunction foo() {\r\n    // return a bound function\r\n    return function (a) {\r\n        console.log( this.a );\r\n    }.bind(this);\r\n}\r\n```\r\n\r\nDoes this just mean that it's possible to defeat the `this` mechanism even when using `bind(..)`?  \r\n\r\nThe last line of the chapter says:\r\n\r\n> They are essentially a syntactic replacement of `self = this` in pre-ES6 coding.\r\n\r\nCouldn't it just as easily have said\r\n\r\n> They are essentially a syntactic replacement of `.bind(this)` in pre-ES6 coding.\r\n\r\nOr is there a nuance that I'm completely missing?"},"comment":{"url":"https://api.github.com/repos/getify/You-Dont-Know-JS/issues/comments/130298908","html_url":"https://github.com/getify/You-Dont-Know-JS/issues/513#issuecomment-130298908","issue_url":"https://api.github.com/repos/getify/You-Dont-Know-JS/issues/513","id":130298908,"user":{"login":"IanVS","id":4616705,"avatar_url":"https://avatars.githubusercontent.com/u/4616705?v=3","gravatar_id":"","url":"https://api.github.com/users/IanVS","html_url":"https://github.com/IanVS","followers_url":"https://api.github.com/users/IanVS/followers","following_url":"https://api.github.com/users/IanVS/following{/other_user}","gists_url":"https://api.github.com/users/IanVS/gists{/gist_id}","starred_url":"https://api.github.com/users/IanVS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IanVS/subscriptions","organizations_url":"https://api.github.com/users/IanVS/orgs","repos_url":"https://api.github.com/users/IanVS/repos","events_url":"https://api.github.com/users/IanVS/events{/privacy}","received_events_url":"https://api.github.com/users/IanVS/received_events","type":"User","site_admin":false},"created_at":"2015-08-12T13:21:24Z","updated_at":"2015-08-12T13:21:24Z","body":"Thanks for explaining and for the further information, that is helpful.  There is a [discussion](https://github.com/eslint/eslint/issues/3357) in ESLint about enforcing the use of arrow functions over `.bind(this)`, so I'm curious what you mean when you say:\r\n\r\n> arrow functions are basically (not entirely) a replacement of the  bind(..)  pattern\r\n\r\nAre they a complete replacement of the `.bind(this)` pattern, if not `bind(..)` in general?"}}