{"action":"created","issue":{"url":"https://api.github.com/repos/petkaantonov/bluebird/issues/444","labels_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/444/labels{/name}","comments_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/444/comments","events_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/444/events","html_url":"https://github.com/petkaantonov/bluebird/issues/444","id":54378407,"number":444,"title":"thisArg not accessible in first function","user":{"login":"johnymonster","id":137058,"avatar_url":"https://avatars.githubusercontent.com/u/137058?v=3","gravatar_id":"","url":"https://api.github.com/users/johnymonster","html_url":"https://github.com/johnymonster","followers_url":"https://api.github.com/users/johnymonster/followers","following_url":"https://api.github.com/users/johnymonster/following{/other_user}","gists_url":"https://api.github.com/users/johnymonster/gists{/gist_id}","starred_url":"https://api.github.com/users/johnymonster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnymonster/subscriptions","organizations_url":"https://api.github.com/users/johnymonster/orgs","repos_url":"https://api.github.com/users/johnymonster/repos","events_url":"https://api.github.com/users/johnymonster/events{/privacy}","received_events_url":"https://api.github.com/users/johnymonster/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-14T21:22:30Z","updated_at":"2015-01-14T21:25:16Z","closed_at":null,"body":"Given the code below.  map's function will not have access to this.  from what I can tell the only way to bind this to the function called by map is to do this:\r\n\r\n```\r\nfunction(item){...}.bind(this);\r\n```\r\nI'm not sure if this is as intended or if I'm missing something.\r\n\r\n```\r\nvar A = function() {\r\n\tthis.b = ['a','b','c'];\r\n};\r\n\r\nA.prototype.tick = function() {\r\n\r\n\tconsole.log(this.b); // gets value of b on this\r\n\r\n\treturn Promise.map(this.b, function(item){\r\n\t\tconsole.log(this.b); // does not get value of b on initialized A object\r\n\t\tthis.getTime(item);\r\n\t\treturn item;\r\n\t});\r\n\r\n};\r\n\r\nA.prototype.getTime = function(item) {\r\n\tconsole.log(this.b);\r\n};\r\n```"},"comment":{"url":"https://api.github.com/repos/petkaantonov/bluebird/issues/comments/69994838","html_url":"https://github.com/petkaantonov/bluebird/issues/444#issuecomment-69994838","issue_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/444","id":69994838,"user":{"login":"spion","id":502412,"avatar_url":"https://avatars.githubusercontent.com/u/502412?v=3","gravatar_id":"","url":"https://api.github.com/users/spion","html_url":"https://github.com/spion","followers_url":"https://api.github.com/users/spion/followers","following_url":"https://api.github.com/users/spion/following{/other_user}","gists_url":"https://api.github.com/users/spion/gists{/gist_id}","starred_url":"https://api.github.com/users/spion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spion/subscriptions","organizations_url":"https://api.github.com/users/spion/orgs","repos_url":"https://api.github.com/users/spion/repos","events_url":"https://api.github.com/users/spion/events{/privacy}","received_events_url":"https://api.github.com/users/spion/received_events","type":"User","site_admin":false},"created_at":"2015-01-14T21:25:16Z","updated_at":"2015-01-14T21:25:16Z","body":"This is [normal JS behavior](https://gist.github.com/spion/7180482). You can use [`Promise.bind`](https://github.com/petkaantonov/bluebird/blob/master/API.md#binddynamic-thisarg---promise) to change it."}}