The difference is scoping.
var is scoped to the nearest function block, and
let is scoped to the nearest enclosing block, which can be smaller than a function block. Both are global if outside any block.
Also, variables declared with
let are not accessible before they are declared in their enclosing block. It will throw a ReferenceError exception.
- 1Bitbucket and Visual Studio
- 1How to dump and restore database in MongoDB
- 1How to compress and extract files/folders using the tar command on Ubuntu
- 1How To Create a New User and Grant Permissions in MySQL
- 2Abstract and Virtual Methods
- 0What is the difference between custom dimensions and metrics in Google Analytics
- 5How can I rename git local and remote branch name?
- 1Events and delegates in C#
- 1how to write function to generate an array between two integers
- 1*ngIf and *ngFor on same element causing error