SOURCE

function myset(){
    var collection=[]
    this.has=function(e){
        return (collection.indexOf(e)!==-1)
    }
    this.value=function(){
        return collection
    }
    this.add=function(e){
        if(!this.has(e)){
            collection.push(e)
            return ture
        }
        return false
    }
    this.remove=function(e){
        if(this.has(e)){
            index=collection.indexOf(e)
            collection.splice(index,1)
            return ture
        }
        return false
    }
    this.size=function(){
        return collection.length
    }
    this.unionset=function(otherset){
        var unionset=new myset()
        var firstset=this.value()
        var secoundset=otherset
        firstset.forEach(function(e){
            unionset.add(e)
        })
        secoundset.forEach(function(e){
            unionset.add(e)
        })
        return unionset
    }
    this.intersection=function(otherset){
        var intersectionset=new myset()
        var firstset=this.value()
        var secoundset=otherset
        first.forEach(function(e){
            if(otherset.has(e)){
                intersectionset.add(e)
            }
        })
        return intersectionset
    }
    this.difference=function(otherset){
        var differenceset=new myset()
        var firstset=this.value()
        firstset.forEach(function(e){
            if(!otherset.has(e)){
                differenceset.add(e)
            }
        })
        return differenceset
    }
    this.subset=function(otherset){
        var firstset=this.value()
        firstset.every(function(value){
            return otherset.has(value)
        })
        }
    }
var seta=new myset()
var setb=new myset()
seta.add("a")
setb.add("b")
setb.add("c")
setb.add("a")
setb.add("d")
console.log(seta.subset(setb))
console 命令行工具 X clear

                    
>
console