🎙 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 12 of 15

What does this print? (code)

What does this print?

console.log(greet());
function greet() { return "hello"; }
  1. A.hello
  2. B.undefined
  3. C.It throws a ReferenceError
  4. D.It throws a TypeError
Answer & explanation

Correct answer: hello

Function declarations are hoisted completely, so they can be called before their line.

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 →