once一次函数
//利用闭包延长变量的生命周期
function once(func){
let flag=true
return function increment(){
if(!flag){
return increment.value
}
flag=false
increment.value=func.apply(this,arguments)
}
}
var index=0
const fun=()=>index++
//调用
const add=once(fun)
add()
add()
add()
console.log(index)