Output prediction · Write code
Hoisting output
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voiceThe interviewer asks
Output, line by line?
console.log(a); var a = 1;
foo(); bar();
function foo() { console.log('foo'); }
var bar = function () { console.log('bar'); };
console.log(b); let b = 2;
Then
Follow-ups the interviewer asks next
- Which line stops execution?
- What if
barwere an arrow function underconst?
The answer
What a strong answer covers
undefined,foo, thenTypeError: bar is not a function, and execution stops- If it continued:
ReferenceError: Cannot access 'b' before initialization
The red pen
Common traps
Avoid:answering undefined for bar().
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voicePractise questions like this out loud
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.