Some error occured while loading page for you. Please try again.
We use cookies to ensure you have the best browsing experience on our website.
Please read our cookie policy for more information about how we use cookies.
The difference is just scoping. var is scoped to the nearest function block (or global if outside a function block), and let is scoped to the nearest enclosing block (or global if outside any block), which can be smaller than a function block.
Also, just like var, variables declared with let are visible before they are declared in their enclosing block, so the purpose of let statements is only to free up memory when not needed in a certain block.
The difference is just scoping. var is scoped to the nearest function block (or global if outside a function block), and let is scoped to the nearest enclosing block (or global if outside any block), which can be smaller than a function block.
Also, just like var, variables declared with let are visible before they are declared in their enclosing block, so the purpose of let statements is only to free up memory when not needed in a certain block.
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/let
Add Reply Preview cancel