Hoisting

Hoisting means - moving the declaration to the top. There are three types of hoisting:

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 ReferenceError , but the value is always Undefined.
  • var

3. No Hoisting

  • OR Technically Hoisted but will give ReferenceError 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
Adesh Tamrakar
SOFTWARE ENGINEER · VAULT

Notes, insights and random discoveries from a working engineer's vault - written for future me, published for you.