Skip to content

Instantly share code, notes, and snippets.

View tvytlx's full-sized avatar
👾
#positive

Xiao Tan tvytlx

👾
#positive
  • Melbourne
  • 11:50 (UTC +11:00)
View GitHub Profile
@tvytlx
tvytlx / sample.txt
Last active April 19, 2017 09:47
ES6 TDZ
规范里用来声明 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
@tvytlx
tvytlx / gist:61e61522b342ced59510c7a8e4f31fe7
Last active April 2, 2017 05:42
这片代码解释了js(es6)的两个问题:let和var的区别,函数传参是 by value 还是 by reference
f = (i)=>{
return ()=>{return i;}
}
var a = []
var b = []
var c = []
(()=>{
  for(var i=0; i<5; i++){