The code you have is invalid in strict mode. Functions are not extracted from blocks (or at least they should not), function declarations inside blocks were completely illegal until ES6. You have to write
"use strict";
var foo;
if (true) {
foo = function() {
alert(1)
};
} else {
foo = function() {
alert(2)
};
}
foo()
.
- , fxn!
, V8 , ES6. "" /, , ( ).