Premise: function literals are bound to their names (unless used anonymously) only when the respective assignment is executed. For example, one can do conditional definition like this:
var fn;
if (some condition) {
fn = function() {
// some code
};
} else {
fn = function() {
// some different code
};
}
Inner functions, on the other hand, behave as if they were always bound to their names, inside the respective scope, disregarding any code path considerations:
function outer() {
inner();
return;
function inner() {
// some code
}
}
My question is, how do inner functions behave when they are defined inside a code block other than a function definition? Is the following supposed to be legal? Is it left undefined by the standard?
function outer() {
if (true) {
inner();
function inner() {
// some code
}
}
}
My tests with this JSFiddle seem to indicate that it works on most browsers, including Chrome, Safari, and IE 8–11, but not on Firefox. Is this a bug in Firefox?