function once(f, obj) {
let count = 0;
let result;
return function() {
count++;
if (count == 1) {
if (obj == undefined) {
obj = {};
}
result = f.apply(obj, arguments);
}
return result;
}
}
let doPayment = once(() => {
console.log("生死由命,富贵在天")
})
doPayment() //生死由命,富贵在天