🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Scope, Closures, Hoisting and this: all 15 questions

Quiz: Scope, Closures, Hoisting and this · Question 3 of 15

What does this print? (code)

What does this print?

console.log(typeof hello);
var hello = "hi";
  1. A.undefined
  2. B.string
  3. C.ReferenceError
  4. D.hi
Answer & explanation

Correct answer: undefined

var declarations are hoisted and start as undefined, so typeof gives "undefined".

Can you get the rest right without peeking?

Take the timed Quiz: Scope, Closures, Hoisting and this quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →