May function declarations appear inside statements in JavaScript?

后端 未结 7 1332
暖寄归人
暖寄归人 2020-11-29 04:34

Please consider the official ECMAScript specification as the source for your answer, and not a document published by a specific browser vendor. (I am aware of Mozilla extend

7条回答
  •  醉梦人生
    2020-11-29 05:24

    Yes it is valid.

    All statement blocks (i.e everything within curly braces) can have additional statements and declarations, including functions.

    So you can also define functions within functions and so on

    Here is ECMA-262 v1 - http://www.mozilla.org/js/language/E262.pdf

提交回复
热议问题