3 ms·
This makes a point for separating the semantics of (a) control flow (a premature exit, similar to break in a loop) and (b) assigning return values. However, Ja
by masswerk 5y ago
This makes a point for separating the semantics of (a) control flow (a premature exit, similar to break in a loop) and (b) assigning return values.
However, JavaScript actually started with rather quirky semantics for return: if any exit returned a value, all exits had to return a value, otherwise an error was thrown. Yet another effect of the nexus of control flow and assignment of a return value. (This got fixed with the introduction of the return object as workaround, which was, I think, in ECMA-Script 3.)