DEV Community

swetha palani
swetha palani

Posted on

1. var, let, and const – Variables & Scope

What is the difference between var, let, and const?

Which keyword is function-scoped and which are block-scoped?

Can you re-declare and re-assign variables declared with each?

What is hoisting, and how does it behave differently for var, let, and const?

What happens if you try to access a let or const variable before declaration?

Explain block scope vs. function scope with examples.

What is hoisting? How does it affect var, let, and const?

What is the Temporal Dead Zone (TDZ)?

Can let or const be re-declared or re-assigned?

Are const objects truly immutable? Why or why not?

Why does var sometimes lead to unexpected behavior in loops?

How does this behave inside different scopes? (Advanced twist)

Top comments (0)