Hoisting means use the variable before it get declared. Simply means you can able to use a variable by assigned the value to variable use it & then declare the variable. We can understand the concept in more better way by using below example.
We will look into this concept by using three small example which shown as below :
In first example, We have declared the variable after assigning the value to variable a. This concept is call as Hoisting. In next example, We have 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 let keyword after assigning value to c, but in output we can clearly seen 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 use only for variable not for let & const keyword & the variable needs to be assigned with value otherwise it will show the error of undefined.