But sometimes understanding these strange concepts are quite frustrating and you may feel lost, don't worry it happens with all of us and whenever you get familiar with these concepts it becomes 'aha...!' movement for you.
Now Without wasting time, let's get into it.
Consider this snippet of code.
a = 2; var a; console.log(a);
What do you think? What will be the output of the above code?
If you think the output will be undefined, No problem when I first saw this code I also thought undefined but the output will be 2. Feels weird, Heres the explanation.
Note:- Hoisting does not work with strict mode.
This was just an introduction part of Hoisting there are lots of scenarios where it can work differently.
I hope you just got a rough idea about it. Thanks for reading and stay tuned for more.