手写简单闭包

809 阅读1分钟
function a() {
    var i = 0

    function b() {
        return i++
    }
    return b
}

var x
x = a()

console.log(x())
console.log(x())
console.log(x())