Skip to main content
All interview theory questions
closureseasy

What is hoisting?

Answer

Declarations are registered when a scope is created, before any code in it runs. Function declarations are fully available, so you can call them above where they're written. var is registered but initialised to undefined. let and const are registered but unusable until their line executes — that gap is the temporal dead zone, and touching them inside it throws a ReferenceError.

Points an interviewer listens for

  • Declarations registered at scope creation, not assignments
  • Function declarations are callable before their line
  • var reads as undefined; let/const throw in the TDZ
  • Function expressions follow their variable's rules

Reported at

Similar questions have been reported by candidates at Deloitte, Neerx Technovation, Photon Technologies, TO THE NEW, Zepto, DotStark Technologies.

Now try answering it out loud

Interview practice mode times your spoken answer and checks it against the points above.

Practise this question

More closures questions