What is hoisting in JavaScript?

JavaScript Associate Easy

JavaScript Associate — Easy

What is hoisting in JavaScript?

Key points

  • Hoisting applies to both variables and functions
  • Declarations are moved to the top of their scope during the compilation phase
  • Only the declarations are hoisted, not the initializations
  • Helps in avoiding reference errors in the code

Ready to go further?

Related questions