Explain the concept of hoisting in JavaScript.
- Hoisting is the process of moving variable and function declarations to the top of their containing scope during compilation.
- Variables declared with
varare hoisted and can be used before declaration (but not initialized). - Function declarations are fully hoisted.