SOURCE

function once(func) {
    let flag = false;
    return function (...args) {
        if (!flag) {
            flag = true;
            return func(...args);
        }
    };
}

let f = function() {
    console.log("124325235");
}

let onceF = once(f);

onceF();
onceF();
onceF();
onceF();
onceF();
console 命令行工具 X clear

                    
>
console