SOURCE

// 使用闭包打印数字累加
    let arr = []
    for(var i = 1;i<10;i++){
        var fn = (function sum(){
            console.log(i)
        })()
        arr.push(fn)
    }

// 学生管理

Array.prototype.remove = function(val) { 
var index = this.indexOf(val); 
if (index > -1) { 
this.splice(index, 1); 
} 
};

function claZZ(){
    var students = []

    function add(name){
        students.push(name)
        return students
    }

    function sub(name){
        students.remove(name)
        return students
    }
    return [add,sub]
}

var x = claZZ()
console.log(x[0]("小妹")) 
console.log(x[0]("小红")) 
console.log(x[1]("小妹")) 
console 命令行工具 X clear

                    
>
console