Why this kind of function invocation is wrong in JavaScript?

我是研究僧i 提交于 2019-11-28 00:19:16

The ECMAScript Language Specification, section 12.4, says:

An ExpressionStatement cannot start with the function keyword because that might make it ambiguous with a FunctionDeclaration.

So your case 1 is not allowed, because it might lead to ambiguities in the language. The other cases are different kinds of statements (not ExpressionStatements) in which this is not a problem, so the construct is allowed there.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!