ES2015 introduced let keywords
Variable declared with var is defined throughout the program as compared to let.
First lets take a look in var keyword.
Key points about var keyword
- It has global scrope,If you declare glbally and it is accessiable throughout the code.
- It can redeclared with the same variable name.
- It get hoisted
Now let keyword
Lets see how to define let keyword
2. let keyword does not have global scope and also it is not hoisted as var.
3.It cannot be declared like
So the Key points about let keyword
- It cab be in global scrope,but cannot be accessed globally.
- It was added in ES6 (ES 2015) version JS
- It cannot be redeclared with the same variable name.
- It will not get hoisted