Difference between let and var keyword
The let statement is used to declare a local variable in TypeScript. It is similar to the var keyword, but it has some restriction in scoping in comparison of the var keyword. The let keyword can enhance our code readability and decreases the chance of programming error. A variable declared with the let keyword is limited to the block-scoped only.
Note: The key difference between var and let is not in the syntax, but it differs in the semantics.
The above code snippet throws an error because the variable "hello" is not defined globally.
Var vs. Let Keyword