javascript - What is the difference between "let" and "var"?

Опубликовано: 01 Октябрь 2024
на канале: Code Samples
31
1

ECMAScript 6 introduced the let statement.
I've heard that it's described as a local variable, but I'm still not quite sure how it behaves differently than the var keyword.
What are the differences? When should let be used instead of var?
another Stack Overflow question: https://stackoverflow.com/questions/7...
hoisted and initialized: https://dev.to/godcrampy/the-secret-o...
hoisted but not initialized: https://stackoverflow.com/questions/3...
the temporal dead zone: https://stackoverflow.com/questions/3...