
Identifier 'a' has already been declared Variable declared with let keyword can be updated but not re-declared. It can be declared globally but cannot be accessed globally. Let The let keyword was added in ES6 (ES 2015) version of JavaScript. Variable declared with var keyword can be re-declared and updated in the same scope. It can be declared globally and can be accessed globally. Var The var keyword was introduced with JavaScript. Error statement will be "ReferenceError: b is not defined." and code will stop executing `let` won't allow reference before definition Error statement will be "TypeError: Assignment to constant variable." and code will stop executing trying to change value of const and then console.logging result will give error `let` or `const` are scoped to the "block", not the function use `let` to declare variables which will change `const` is used to initialize-once, read-only thereafter use `const` to declare variables which won't change Here's about let and const: // Let and Const Example: // log(myName) // output: ReferenceError: myName is not defined and code stops executing trying to execute function with undefined variable for undefined var //output error is 'undefined' and code continues executing var can be defined as last line and will be hoisted to top of code block

var is hoisted to the top of the function, regardless of block Here are some notes that I took that helped me on this subject. If you find that you need to update a variable or change it, then go back and switch it from const to let. Since const is the strictest way to declare a variable, it is suggest that you always declare variables with const because it'll make your code easier to reason about since you know the identifiers won't change throughout the lifetime of your program.

Let and const also have some other interesting properties. This behavior prevents variables from being accessed only until after they’ve been declared. In other words Example: const something = ), then the variable is stuck in what is known as the temporal dead zone until the variable’s declaration is processed. The difference between let and const is that once you bind a value/object to a variable using const, you can't reassign to that variable.
