I've written the following snippet of code:
var f = function() { document.write("a"); };
function foo() {
f();
var f = function() { document.write("b"); };
}
foo();
I expected the function that prints a
to be called, but it instead gives a runtime error about calling an undefined
value. Why does this happen?