JavaScript Variable Hoisting Interview question, var initialised with undefined

Опубликовано: 24 Июль 2026
на канале: JavaScript Shorts
314
4

JavaScript Variable Hoisting Interview question with var initialised as undefined initially

Output: true

Explanation:
During the creation phase variable x initialised with var keyword is hoisted to the top and its value is set undefined
During the execution phase when the console statement is executed value of x is undefined and true is printed in console
Then var x is set to value 2

#interview_questions