js 数组去重复键

Array.prototype.deleteEle = function() {
            var newArr = this;
            for (var i = newArr.length - 1; i >= 0; i--) {
                var targetNode = newArr[i];
                for (var j = 0; j < i; j++) {
                    if (targetNode == newArr[j]) {
                        newArr.splice(i, 1);
                        break;
                    }
                }
            }
            return newArr;
        }

调用:array.deleteEle ();

posted @ 2014-12-15 11:21  等待是一生最初的苍老  阅读(211)  评论(0编辑  收藏  举报