Home | Mailing List | Blog | Tutorial Videos

Hoisting

Consider the following declarations and expression. What gets logged?

immaBeOnTop();

var immaBeOnTop;

function immaBeOnTop() {
  console.log('first');
}

immaBeOnTop = function() {
  console.log('second');
};

What gets logged here?

foo();

function foo() {
  console.log(1);
}

var foo = function() {
  console.log(2);
};

function foo() {
  console.log(3);
}

foo();

Select one: