Question #41

Author: admin
tags: JavaScript  
console.log(typeof f);

if (true) {
  console.log(typeof f);
  function f() { }
  console.log(typeof f);
}

console.log(typeof f);
What will the console output be?
function, function, function, function
undefined, function, function, undefined
undefined, function, function, function
undefined, undefined, function, function
undefined, undefined, function, undefined
undefined, undefined, undefined, undefined
Nothing, there is an error in the code.
Modern browsers show: undefined, function, function, function.
It is strongly not recommended to use Function Declaration inside the if block, because the behavior of browsers may vary.
If for some reason you need to create a function in the if block, then you need to use Function Expression.
Rate the difficulty of the question:
easyhard