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

I think let and const will actually be hoisted in their scope #86

Open
DanielWLam opened this issue Jan 25, 2017 · 1 comment
Open

I think let and const will actually be hoisted in their scope #86

DanielWLam opened this issue Jan 25, 2017 · 1 comment

Comments

@DanielWLam
Copy link

when you declare a variable with var, it will be hoisted and set value as undefined.
I think let and const are so similar but they are passed the default value 'ReferenceError'

@DrkSephy
Copy link
Owner

@DanielWLam you are correct. let and const declarations are hoisted, however if you try to reference these variables before they are declared, a ReferenceError is thrown (regardless of the hoisting. This is also known as the Temporal Dead Zone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants