Hoisting is a JavaScript mechanism where variable and function declarations are conceptually moved to the top of their scope before code execution begins. However, variable assignments are not hoisted.
console.log(x); // Output: undefined (variable is declared but not assigned)
var x = 10;
function myFunction() {
console.log(y); // Output: undefined (function is declared but not assigned)
var y = 20;
}
myFunction();