SOURCE

const counter = (function() {
    let value = 0
    return function() {
        return value++
    }
})()

console.log(counter())
console.log(counter())
console 命令行工具 X clear

                    
>
console