Last active
April 19, 2017 09:47
-
-
Save tvytlx/25d608bafd4d987c58cac93ca895b614 to your computer and use it in GitHub Desktop.
ES6 TDZ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
规范里用来声明 var/let 变量的内部方法是 CreateMutableBinding(),初始化变量用 InitializeBinding(),为变量赋值用 SetMutableBinding(), | |
引用一个变量用 GetBindingValue()。在执行完 CreateMutableBinding() 后没有执行 InitializeBinding() 就执行 SetMutableBinding() 或者 | |
GetBindingValue() 是会报错的,这种表现有个专门的术语(非规范术语)叫 TDZ(Temporal Dead Zone)。 | |
标准说用let和const初始化失败的变量将会永久的不能初始化了。 | |
let/const v = xx // xx is not defined | |
let/const v = 1 // v has already been declared | |
v = 1; let c = v // v is not defined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment