Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let scope is not well supported #21370

Closed
tiancaiamao opened this issue Jun 16, 2018 · 3 comments
Closed

let scope is not well supported #21370

tiancaiamao opened this issue Jun 16, 2018 · 3 comments
Labels
invalid Issues and PRs that are invalid. question Issues that look for answers. wrong repo Issues that should be opened in another repository.

Comments

@tiancaiamao
Copy link

I'm new to node and javascript, I expect this code should work:

function test() {
    let TMP = false;
    (function() {
        let TMP = TMP || true;
    })();
}
test()

but when I run it, I get this error:

ReferenceError: TMP is not defined
@apapirovski
Copy link
Member

You're redeclaring TMP in that scope which means you can't access the outside TMP anymore.

In general, this tracker is for issues or bugs in Node.js core. This question would be better suited to https://github.com/nodejs/help/issues.

@apapirovski apapirovski added question Issues that look for answers. wrong repo Issues that should be opened in another repository. labels Jun 16, 2018
@ghost
Copy link

ghost commented Jun 16, 2018

@tiancaiamao

That is called temporal dead zone (TDZ). It's working per spec.

@ChALkeR ChALkeR added the invalid Issues and PRs that are invalid. label Jun 16, 2018
@tiancaiamao
Copy link
Author

Thank you for point out that. @trvsapjiac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Issues and PRs that are invalid. question Issues that look for answers. wrong repo Issues that should be opened in another repository.
Projects
None yet
Development

No branches or pull requests

3 participants