去空格,优化addArray,removeArray性能

This commit is contained in:
kuangshen04 2023-10-08 15:19:27 +08:00
parent e0f9e919c7
commit 27ddea0730
1 changed files with 135 additions and 134 deletions

View File

@ -8487,7 +8487,8 @@
enumerable:false,
writable:true,
value:function(){
return Array.prototype.add.apply(this,Array.from(arguments).flat());
for(const i of arguments) this.add(...i);
return this;
}
});
Object.defineProperty(Array.prototype,"remove",{
@ -8508,7 +8509,7 @@
enumerable:false,
writable:true,
value:function(){
return Array.prototype.remove.apply(this,Array.from(arguments).flat());
for(const i of arguments) this.add(...i);
}
});
Object.defineProperty(Array.prototype,"unique",{
@ -8516,7 +8517,7 @@
enumerable:false,
writable:true,
value:function(){
let uniqueArray = this.toUniqued();
let uniqueArray=[...new Set(this)];
this.length=uniqueArray.length;
for(let i=0;i<uniqueArray.length;i++) this[i]=uniqueArray[i];
return this;
@ -8575,11 +8576,11 @@
enumerable:false,
writable:true,
value:function(){
var list = [];
let list=[];
while(this.length){
list.push(this.randomRemove());
}
for (var i = 0; i < list.length; i++) {
for(let i=0;i<list.length;i++){
this.push(list[i]);
}
return this;