Title: closures - uninitialized vs undefined · Issue #3895 · javascript-tutorial/en.javascript.info · GitHub
Open Graph Title: closures - uninitialized vs undefined · Issue #3895 · javascript-tutorial/en.javascript.info
X Title: closures - uninitialized vs undefined · Issue #3895 · javascript-tutorial/en.javascript.info
Description: in this article, we are discussing lexical environments, and the scope of variables. upon initialization, variables are defined as
Open Graph Description: in this article, we are discussing lexical environments, and the scope of variables. upon initialization, variables are defined as
X Description: in this article, we are discussing lexical environments, and the scope of variables. upon initialization, variables are defined as <unitialized> because "the engine knows about the varia...
Opengraph URL: https://github.com/javascript-tutorial/en.javascript.info/issues/3895
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"closures - uninitialized vs undefined","articleBody":"in [this article](https://javascript.info/closure), we are discussing lexical environments, and the scope of variables. \nupon initialization, variables are defined as `\u003cunitialized>` because \"[the engine knows about the variable, but it cannot be referenced until it has been declared with `let`](https://javascript.info/closure#step-1-variables)\"\n\n\u003cimg width=\"640\" height=\"181\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/5f1df08d-5c9a-4fcd-9145-3d851ec9736b\" />\n\n\u003cimg width=\"577\" height=\"168\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/67fe9294-305a-4e86-a2a2-ffbf7d7a715e\" />\n\nlater in the article, when referencing nested lexical environments in functions, a variable is initialized as `undefined`. from my understanding, this is incorrect, as the engine knows about the variable, but is not referenced yet since it hasn't been declared.\n\n\u003cimg width=\"738\" height=\"181\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/70efb1f1-81a4-4fae-8ea2-31c708084984\" />\n\n\u003cimg width=\"808\" height=\"183\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/85378e91-356c-42a6-bbac-372ce2bc5c9b\" />\n\ni believe that we need to change the following SVG's to reflect this change:\nhttps://github.com/javascript-tutorial/en.javascript.info/blob/master/1-js/06-advanced-functions/03-closure/lexenv-nested-makecounter-2.svg\nhttps://github.com/javascript-tutorial/en.javascript.info/blob/master/1-js/06-advanced-functions/03-closure/lexenv-nested-makecounter-3.svg\n\n\nif this is an incorrect assumption, please help me understand why it's undefined instead of uninitialized! i'd love to learn more about how this all works.","author":{"url":"https://github.com/aredmondd","@type":"Person","name":"aredmondd"},"datePublished":"2025-10-17T12:18:26Z","url":"https://github.com/javascript-tutorial/en.javascript.info/issues/3895"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:15eba3c8-8873-94af-bb8c-72b8e165e174 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8B9E:2668B6:A965BD:E78241:6AFBDB60 |
| html-safe-nonce | 8797e70833ff9a83727f59535516366d98141f53ba60a2706fe2e5f12542f3d1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjlFOjI2NjhCNjpBOTY1QkQ6RTc4MjQxOjZBRkJEQjYwIiwidmlzaXRvcl9pZCI6IjM3MTMwNjUzOTc0NTMwNTI3NjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8065dc6b3d3178186566529308ec5044962a9c29a5b93bde90b859841b294942 |
| hovercard-subject-tag | issue:3525933418 |
| 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/javascript-tutorial/en.javascript.info/3895/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c4d2e7660344edbb0413aa02966a4efa6614f2ffd683fdf83ce1eb5f99659d7b/javascript-tutorial/en.javascript.info/issues/3895 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c4d2e7660344edbb0413aa02966a4efa6614f2ffd683fdf83ce1eb5f99659d7b/javascript-tutorial/en.javascript.info/issues/3895 |
| og:image:alt | in this article, we are discussing lexical environments, and the scope of variables. upon initialization, variables are defined as |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | aredmondd |
| hostname | github.com |
| expected-hostname | github.com |
| None | 18742cb872ec73544356e60359266b67aafece70c4ce008042e06227924cdd07 |
| turbo-cache-control | no-preview |
| go-import | github.com/javascript-tutorial/en.javascript.info git https://github.com/javascript-tutorial/en.javascript.info.git |
| octolytics-dimension-user_id | 49552305 |
| octolytics-dimension-user_login | javascript-tutorial |
| octolytics-dimension-repository_id | 93253246 |
| octolytics-dimension-repository_nwo | javascript-tutorial/en.javascript.info |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 93253246 |
| octolytics-dimension-repository_network_root_nwo | javascript-tutorial/en.javascript.info |
| 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 | 820be804f18e1ef3940bd74a00d41d73d02e2b91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width