美文网首页
2019-04-14 javascript 之数组去重

2019-04-14 javascript 之数组去重

作者: esbook | 来源:发表于2019-04-14 21:59 被阅读0次

    Array.prototype.unique = function(){

        var arr=[],

            tem={},

            len = this.length;

             for(var i=0;i<len;i++){

                if(!temp[this[i]]){

                    temp[this[i]]='temp'

                    arr.push(this[i])

                }

            }    

        return arr

    }

    相关文章

      网友评论

          本文标题:2019-04-14 javascript 之数组去重

          本文链接:https://www.haomeiwen.com/subject/aldewqtx.html