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

Asked 2023-09-20 19:59:17 View 838,658

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?

Answers