What is hoisting and what do you know about it?

Experience Level: Mid-level
Tags: JavaScript

Answer

Hoisting is JavaScript's default behavior of moving declarations to the top.

  • In JavaScript, a variable can be declared after it has been used. In other words; a variable can be used before it has been declared.
  • JavaScript only hoists declarations, not initializations.
Related JavaScript job interview questions