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());
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());