Do you know what will be the output of this code?
JavaScript
console.log(greet());
var greet = function () {
return "hi";
};
Show answer and explanation
The answer is TypeError: greet is not a function.
var greet is hoisted and set to undefined. The function is only assigned when that line runs. Calling undefined() throws a TypeError.