JS 闭包与作用域
函数自执行 Document .box{ width: 100px; height: 100px; background: red; } .box2{ width: 100px; height: 100px; background: yellow; } var box = document.querySelector(...
标签文章 2 篇
函数自执行 Document .box{ width: 100px; height: 100px; background: red; } .box2{ width: 100px; height: 100px; background: yellow; } var box = document.querySelector(...
// 闭包 // 函数套函数 子函数调用父函数的局部变量 - 闭包 function fn(){ var a = 5; function fn2(){ console.log(a); } fn2(); } fn(); 闭包能做什么 示例:点击不同的按钮打印不同的下标 按钮1 按钮2 按钮3 var btns = doc...