21 1 的输出结果不完全正确,在不同的浏览器下结果不同
在safari下结果为21 21
在chrome下结果为21 1
同时ECMAScript规范中说函数声明可以嵌套在条件语句块内,但是其运行的结果依赖于JS解析器的实现,其结果具有不确定性,不推荐在生产环境下使用
Functions can be conditionally declared, that is, a function statement can be nested within an if
statement, however the results are inconsistent across implementations and therefore this pattern should not be used in production code. For conditional function creation, use function expressions instead.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…