Function Statement Example - FAQ : "What is a function statement?"

Example Code

try {
  x; // ReferenceError: x is not defined.
  function Fze(a, b) {a.unselectable = b}
} catch(e) { }

document.write("typeof Fze: ", typeof Fze, "\ntypeof e: ", typeof e);

Result


Expected outcome for typeof Fze is not specified by ECMA-262.

If typeof Fze results "function", then Fze was interpreted as a FunctionDeclaration. Otherwise if typeof Fze resulted "undefined", then Fze was not reached as a Statement; the preceeding statement - x; - would trigger a ReferenceError, making it unreachable.

Expected outcome for typeof e is "undefined".