What is the difference between `var`, `let`, and `const` regarding block scoping?

JavaScript Associate Medium

JavaScript Associate — Medium

What is the difference between `var`, `let`, and `const` regarding block scoping?

Key points

  • `var` is function-scoped and hoisted
  • `let` and `const` are block-scoped
  • Temporal dead zone affects `let` and `const`
  • `var` is accessible throughout the function

Ready to go further?

Related questions