Javascript 什么是退货?[错误?]

Javascript 什么是退货?[错误?],javascript,google-chrome,google-chrome-devtools,Javascript,Google Chrome,Google Chrome Devtools,我用两个例子来说明我的问题: /// first script function a(){} /// Outputs: undefined 您可以在chrome开发工具中运行这两个示例。 现在让我们看一下规范: 14.1.21运行时语义:评估 FunctionDeclaration:functionBindingIdentifier(FormalParameters){FunctionBody} 返回NormalCompletion(空) 注1 B.3.3中提供了另一种语义。 Functio

我用两个例子来说明我的问题:

/// first script
function a(){}
/// Outputs: undefined

您可以在chrome开发工具中运行这两个示例。 现在让我们看一下规范:

14.1.21运行时语义:评估

FunctionDeclaration:functionBindingIdentifier(FormalParameters){FunctionBody}

  • 返回NormalCompletion(空)
  • 注1 B.3.3中提供了另一种语义。

    FunctionDeclaration:function(FormalParameters){FunctionBody}

  • 返回NormalCompletion(空)
  • 所以您可以看到FunctionDeclaration必须返回
    完成([[Value]]:空)

    chrome开发工具在撒谎吗


    第二个示例中的p.S Firefox输出:未定义的

    在@wOxxOm good中报告。注意:在严格模式下,我得到“use strict”,意思是:块的值为空,字符串的值为“use strict”。一起将不是空值-“使用严格”
    /// second script
    {
       function a(){}
    }
    /// Outputs: f a(){}