SOURCE

const test = (a, b) => {
    let res = a + b
    console.log(res)
}
const memo = (fn) => {
    let cache = {}
    return () => {
        if (!cache[fn]) {
            cache[fn] = fn
            fn()
            return
        }
    }

}
const s = memo(test(1,2))
const m = memo(test(1,2))
const n = memo(test(3,4))
s()
s()
m()
console 命令行工具 X clear

                    
>
console