Successfully added
JavaScript
by Patrik
Hoisting of const
Just like let, const declarations are hoisted to the top but are not initialized.
So just in case you missed the differences, here they are:
vardeclarations are globally scoped or function scoped whileletandconstare block-scoped.varvariables can be updated and re-declared within its scope;letvariables can be updated but not re-declared;constvariables can neither be updated nor re-declared.- They are all hoisted to the top of their scope. But while
varvariables are initialized withundefined,letandconstvariables are not initialized. - While
varandletcan be declared without being initialized,constmust be initialized during declaration.
Referenced in:
Comments