What is the difference between "var" and "let"?

There are mainly 4 major differences between var & let.

  1. Scoping - var is scoped to the nearest function block while let is scoped to the nearest enclosing block.
  2. Redeclarations -var allows redeclaration of a variable in the same block while let doesn't.
  3. JavaScript Hoisting - Variables and constants declared with let or const are not hoisted.
  4. Global Window Object - Global variables declared with let are not added as property on the global window object.