数组去重,地址不改变 王东煜 2019-09-20 183 阅读1分钟 var ary = [1,1,2,3,3,4,5,6,6];Array.prototype.unique = function(){let arr = [...new Set(this)]//实现去重this.length = 0;//数组长度清零this.push(...arr);//把去重的push进原数组return this;//返回这个去重后的实例}console.log(ary.unique());