Do you know what will be the output of this code?
JavaScript
function f() {
return 1;
}
function f() {
return 2;
}
console.log(f());
Show answer and explanation
The answer is 2.
Both declarations are hoisted before any code runs, and the later one replaces the earlier one. With let or const this would be a SyntaxError.