function fun(){
var num = 1;
reSet = function(){
num = 1;
console.log(num);
}
return function(){
num++;
console.log(num);
}
}
var f = fun();
f();
reSet();
优点:
1、可以读取函数内部的变量;
2、让变量的值始终保持在内存中;
function fun(){
var num = 1;
reSet = function(){
num = 1;
console.log(num);
}
return function(){
num++;
console.log(num);
}
}
var f = fun();
f();
reSet();
优点:
1、可以读取函数内部的变量;
2、让变量的值始终保持在内存中;