JavaScript by Patrik

Hoisting of const

Just like letconst declarations are hoisted to the top but are not initialized.

So just in case you missed the differences, here they are:

  • var declarations are globally scoped or function scoped while let and const are block-scoped.
  • var variables can be updated and re-declared within its scope; let variables can be updated but not re-declared; const variables can neither be updated nor re-declared.
  • They are all hoisted to the top of their scope. But while var variables are initialized with undefinedlet and const variables are not initialized.
  • While var and let can be declared without being initialized, const must be initialized during declaration.

Comments