閉包就是兩個函數嵌套,內部函數引用外部函數變量,例如:閉包
function fn1(){ let a = "1" let fn2 =function (){ console.log(a) } return fn2 } let fn3 = fn1() 複製代碼