Javascript
Apr 15, 2026
What gets logged?
function foo() {
console.log(a)
var a = 10
}
foo()
Explanation
Hoisting. var declarations are moved to the top of their function scope, but values are not.
📝
Reviewed by CodeShot Editorial
Every challenge is code-reviewed by senior developers to ensure accuracy and real-world relevance. Learn more.