let count = 0; // after(3,log)('hi')这种用法count = 0只能放在这里
function after(times,callback){
//var log = after(3,log)
//log(1) 这种用法,count = 0只能放在这里核下面都一样
let count = 0;
return function(...args){
count++
if(count === times) {
callback.apply(this,args)
}
}
}
function log(info){
console.log(info);
}
var log = after(3,log)
log(1)
log(2)
log(3) // 执行后才会有输出3
// after(3,log)('hi')
// after(3,log)('hi')
// after(3,log)('hi')