Hoisting means - moving the declaration to the top. Three types of hoisting are there :
1. Value hoisting
- Can use the variable in its scope before the line its declared.
- ==function, function, async function, async function==**
2. Declaration hoisting
- Only the declaration is hoisted, means it can be accessed before the declaration line and will not give
ReferrenceError
, but the value is alwaysUndefined
. - var
3. No Hoisting
- OR Technically Hoisted but will give
ReferrenceError
if accessed before its declaration, So it can be simply called No Hoisting - The zone until variable can’t be accessed is called the Temporal Dead Zone - TDZ
- let, const, functions expressions