I learned that the following does not work in FF and does in every other standard browser.
if(jQuery){
importantScript();
function importantScript(){
console.log("this is important");
};
}
This is because FF does not hoist functions within if statements. It sounds like this used to be a rule, but I was reading page 533 (B.3.3) and B.3.4 here are the cliff notes :
Prior to ECMAScript 2015, the ECMAScript specification did not define the occurrence of a FunctionDeclaration as an element of a Block statement’s StatementList. However, support for that form of FunctionDeclaration was an allowable extension and most browser-hosted ECMAScript implementations permitted them. Unfortunately, the semantics of such declarations differ among those implementations. Because of these semantic differences, existing web ECMAScript code that uses Block level function declarations is only portable among browser implementation if the usage only depends upon the semantic intersection of all of the browser implementations for such declarations. The following are the use cases that fall within that intersection semantics:
A function is declared and only referenced within a single block
A function is declared and possibly used within a single Block but also referenced by an inner function definition that is not contained within that same Block.
A function is declared and possibly used within a single block but also referenced within subsequent blocks
Can you help me interpret this? I feel that the code above would meet the technical rules described above.