闭包

1.概念 能够读取其它函数作用域里变量的函数 2.应用 // 2.1累加器 function hd(){ let n = 0 return ()=>{ console.log(++n) } } const sum = hd() sum() sum() // 2.2类 function Hd(){ t
posted @ 2021-08-29 11:03  卷叶小树  阅读(29)  评论(0编辑  收藏  举报