摘要:
闭包的样列例子1:闭包中局部变量是引用而非拷贝function say667() { // Local variable that ends up within closure var num = 666; var sayAlert = function() { alert(num); } num++; return sayAlert;} var sayAlert = say667();sayAlert()因此执行结果应该弹出的667而非666。例子2:多个函数绑定同一个闭包,因为他们定义在同一个函数内。function setupSomeGlobals() { ... 阅读全文