What’s the difference between “let” and “var” to declare a variable?

The difference is scoping. var is scoped to the nearest function block and islet scoped to the nearest enclosing block, which can be smaller than a function block. Both are global if outside any block.

 

Ref: https://stackoverflow.com/questions/762011/whats-the-difference-between-using-let-and-var-to-declare-a-variable

Add a Comment

Your email address will not be published. Required fields are marked *