Title: [question] Why do many files in the lib directory use `var` sometimes and `let` other times? · Issue #28009 · nodejs/node · GitHub
Open Graph Title: [question] Why do many files in the lib directory use `var` sometimes and `let` other times? · Issue #28009 · nodejs/node
X Title: [question] Why do many files in the lib directory use `var` sometimes and `let` other times? · Issue #28009 · nodejs/node
Description: Version: 12.3.1 While looking through the node.js source code, I have found quite a few var declarations. In the same files I have also found let declarations. let declarations are almost always considered better, and can always be used ...
Open Graph Description: Version: 12.3.1 While looking through the node.js source code, I have found quite a few var declarations. In the same files I have also found let declarations. let declarations are almost always co...
X Description: Version: 12.3.1 While looking through the node.js source code, I have found quite a few var declarations. In the same files I have also found let declarations. let declarations are almost always co...
Opengraph URL: https://github.com/nodejs/node/issues/28009
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[question] Why do many files in the lib directory use `var` sometimes and `let` other times?","articleBody":"\u003c!--\r\nThank you for reporting an issue.\r\n\r\nThis issue tracker is for bugs and issues found within Node.js core.\r\nIf you require more general support please file an issue on our help\r\nrepo. https://github.com/nodejs/help\r\n\r\n\r\nPlease fill in as much of the template below as you're able.\r\n\r\nVersion: output of `node -v`\r\nPlatform: output of `uname -a` (UNIX), or version and 32 or 64-bit (Windows)\r\nSubsystem: if known, please specify affected core module name\r\n\r\nIf possible, please provide code that demonstrates the problem, keeping it as\r\nsimple and free of external dependencies as you are able.\r\n--\u003e\r\n\r\n* **Version**: 12.3.1\r\n\r\n\u003c!-- Enter your issue details below this comment. --\u003e\r\nWhile looking through the node.js source code, I have found quite a few `var` declarations. In the same files I have also found `let` declarations. `let` declarations are almost always considered better, and can always be used in place of `var` declarations. I was thinking about fixing this and creating a PR but wanted to know if there was a specific reason for using `var` sometimes and `let` other times. Scope could be a reason, but could be transformed like this:\r\n\r\n```js\r\nif(/*...*/) {\r\n var foo = 'bar';\r\n}\r\n\r\n//is the same as\r\nlet foo;\r\nif(/*...*/) {\r\n foo = 'bar';\r\n}\r\n```\r\n","author":{"url":"https://github.com/MilesZew","@type":"Person","name":"MilesZew"},"datePublished":"2019-06-01T20:32:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/28009/node/issues/28009"}
| 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:7bec5a77-be2c-f277-2f98-ab7d35e08530 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9590:12DB27:72946:A376D:6A4F986E |
| html-safe-nonce | fbc34270cf1464102e0d74e0d02f4d0f80923977559621917c59369cde8cfba6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTkwOjEyREIyNzo3Mjk0NjpBMzc2RDo2QTRGOTg2RSIsInZpc2l0b3JfaWQiOiI4MTU4NzA2MDUxNzY1NDc1NDM4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | fa35bda1ca0a4c7be32c2c6a089dbbbf95b1cf3caab1a634c1ba116c17b1d42a |
| hovercard-subject-tag | issue:451121906 |
| 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/28009/issue_layout |
| twitter:image | https://opengraph.githubassets.com/04b802b339d668863d08f31e7f7d90b02e8a9eda2f80f402a19add363cb590db/nodejs/node/issues/28009 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/04b802b339d668863d08f31e7f7d90b02e8a9eda2f80f402a19add363cb590db/nodejs/node/issues/28009 |
| og:image:alt | Version: 12.3.1 While looking through the node.js source code, I have found quite a few var declarations. In the same files I have also found let declarations. let declarations are almost always co... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MilesZew |
| 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