ecmascript-6 - BindingIdentifier 和 IdentifierReference 有什么区别
问题描述
让我们看看http://www.ecma-international.org/ecma-262/#sec-expressions
如你看到的:
IdentifierReference[Yield, Await]:
Identifier
[~Yield]yield
[~Await]await
BindingIdentifier[Yield, Await]:
Identifier
[~Yield]yield
[~Await]await
Identifier:
IdentifierName but not ReservedWord
两者都Identifiers (Binding and Reference)
包含相同的东西。这有什么意义?它们有什么不同?
解决方案
关键是它们出现在不同的上下文中,并且有不同的算法与之相关。
- An
IdentifierReference
是在表达式中使用的变量名,使用ResolveBinding对引用进行评估 - A
BindingIdentifier
是用于创建绑定的变量名 - 在变量和函数声明中、在参数中、在解构中、在catch
子句中、在for
子句中等。
在它们的EarlyErrors中, anIdentifierReference
可能指的是eval
or argument
,但是BindingIdentifier
为它们创建绑定是一个语法错误(在严格模式下)。他们共享的唯一算法是StringValue。AnIdentifierReference
具有IsValidSimpleAssignmentTarget检查和Evaluation,而 aBindingIdentifier
具有BoundNames和BindingInitialisation过程。
推荐阅读
- html - 有什么方法可以在表格中搜索并显示多个连接的 tr
- flutter - Flutter_local_notifications 中的 Flutter onSelectNotification 方法不起作用
- javascript - 如何在 View 的 ImageBackround 中添加 createStackNavigator 以获得公共背景图像?
- docker - 在没有特权或 SYS_ADMIN 模式的情况下将 s3 挂载到 docker 容器
- java - @Mock 注解不适用于对象映射器
- fortran - 使用八度音阶的 fortran 的更快方法
- sql - 为什么相同几何的 ST_Equals 返回 false?
- python - 无法使用套接字连接到热点连接上的服务器
- flutter - flutter_bloc 共享多个 bloc 的状态
- c++ - 如何使用来自另一个分支的类指针访问层次结构一个分支的类的成员?