Hoisting means using the variable before it gets declared. Simply means you can able to use a variable by assigning the value to variable use it & then declare the variable. We can understand the concept in a better way by using the below example.
We will look into this concept by using three small examples which are shown below :
In the first example, We have declared the variable after assigning the value to variable a. This concept is called Hoisting. In the next example, We have to use the variable without assigning the value to the variable & declare it, therefore we get the error as undefined. We have declared the value using the let keyword after assigning value to c, but in output, we can clearly see that it logs the error like ‘Uncaught ReferenceError: Cannot access ‘c’ before initialization at index.html:27′. In this way, it proves that Hoisting can be used only for variables not for the let & const keyword & the variable needs to be assigned with value otherwise it will show the error of undefined.