【问题标题】:What‘s the difference between "identifier" and "identifierName" in ECMAScript 2020?ECMAScript 2020 中的“identifier”和“identifierName”有什么区别?
【发布时间】:2021-09-01 03:35:35
【问题描述】:

https://262.ecma-international.org/11.0/#prod-IdentifierName 我不太了解 ECMAScript 2020 中“标识符”和“标识符名称”之间的区别。

【问题讨论】:

  • 你能在这里引用相关部分的简短sn-p吗...?

标签: javascript ecmascript-2020


【解决方案1】:

在 ECMAScript 规范中,词法 语法对保留字一无所知;任何类似单词的东西都被识别为 IdentifierName。然后由 syntactic 级别决定如何处理 IdentifierName。如果 IdentifierName 与 ReservedWord 产生式不匹配,则它有资格作为 Identifier,并且(大致上)可以在您期望标识符的所有地方使用。 (完整的规则有些复杂:请参阅12.6.2 Keywords and Reserved Words 了解摘要。)

【讨论】:

    【解决方案2】:

    答案在你自己链接的文档中,用一句话简明扼要:

    句法语法将 Identifier 定义为不是 ReservedWord 的 IdentifierName。

    【讨论】:

      猜你喜欢
      • 2014-03-02
      • 2010-10-29
      • 2020-05-23
      • 2012-08-16
      • 2014-04-14
      • 2020-06-06
      • 2014-01-09
      • 1970-01-01
      相关资源
      最近更新 更多