You can access them before they are declared. In such case, their value would be undefined though, as only declarations and not initializations are hoisted. This is generally considered a bad practice. … You can access it only after it was declared.
Is hoisting a bug?
Are VARS hoisted?
Variables declared using var are created before any code is executed in a process known as hoisting. Their initial value is undefined .
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.