if (true) {
function foo(){ return 1; }
}
else {
function foo(){ return 2; }
}
foo();
The above code is an example of function expression and returns 1 in Firefox 28 whereas 2 in Chrome ( expected result). Why is firefox giving wrong result ?
chromeloads the functional expressions before executing any line of code, whereasfirefoxdoes when its interpreter reaches the line of declaration of the functions?foo()declaration would replace its first declaration?