Title: Arrow functions' lexical binding is not working correctly · Issue #735 · nodejs/node · GitHub
Open Graph Title: Arrow functions' lexical binding is not working correctly · Issue #735 · nodejs/node
X Title: Arrow functions' lexical binding is not working correctly · Issue #735 · nodejs/node
Description: The arrow function is supposed to bind to the scope in which it is defined (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions), and the this of an arrow function should not be able to change. As ...
Open Graph Description: The arrow function is supposed to bind to the scope in which it is defined (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions), and the this of an arrow fu...
X Description: The arrow function is supposed to bind to the scope in which it is defined (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions), and the this of an arrow fu...
Opengraph URL: https://github.com/nodejs/node/issues/735
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Arrow functions' lexical binding is not working correctly","articleBody":"The arrow function is supposed to bind to the scope in which it is defined (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions), and the `this` of an arrow function should not be able to change. As shown in the code below (run with the `--harmony_arrow_functions`), the arrow functions are not correctly binding.\n\n``` js\nvar obj = {\n init: function() {\n this.handle(this.cb);\n },\n cb: val =\u003e {\n console.log(this.val);\n console.log(val);\n return val + this.val;\n },\n handle: function(cb) {\n console.log(cb(3));\n },\n val: 5\n};\n\nconsole.log('calling cb directly');\nconsole.log(obj.cb(3));\n// 5\n// 3\n// 8\n\nconsole.log('calling cb via init');\nobj.init();\n// undefined\n// 3\n// NaN\n```\n","author":{"url":"https://github.com/smfoote","@type":"Person","name":"smfoote"},"datePublished":"2015-02-05T23:24:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/735/node/issues/735"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7aceceaa-5e4e-dfc5-c34f-2b1a05b2e661 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CB3C:3C8683:4151EFB:5C3B374:6A4FB67B |
| html-safe-nonce | 07365b7c2509ec59187a351f99d1ad14fa35583889bc0d8aca18d93a5952a150 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjNDOjNDODY4Mzo0MTUxRUZCOjVDM0IzNzQ6NkE0RkI2N0IiLCJ2aXNpdG9yX2lkIjoiNjE3NTkwNzA1MjM4MjkyMDkxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 93ab1a835340f8a65d42752ba159f9486253aadbc9ee4af399472f34245736cb |
| hovercard-subject-tag | issue:56746252 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/735/issue_layout |
| twitter:image | https://opengraph.githubassets.com/84de890de18e32f24652467a9139d4303ad81e0fb5f15518ce0908f771cc0c05/nodejs/node/issues/735 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/84de890de18e32f24652467a9139d4303ad81e0fb5f15518ce0908f771cc0c05/nodejs/node/issues/735 |
| og:image:alt | The arrow function is supposed to bind to the scope in which it is defined (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions), and the this of an arrow fu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | smfoote |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4b249b445842943ed31549e027f57a8ade9881ed |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width