diff --git a/game/game.js b/game/game.js index 29edb2a08..60fc30ae1 100644 --- a/game/game.js +++ b/game/game.js @@ -8497,25 +8497,9 @@ configurable:true, enumerable:false, writable:true, - //与原来参数的对比: - //数据多,比原来的函数快 - //数据少,比原来的函数稍慢 value:function(){ - if(arguments.length>0){ - //参数去重,防止出现addArray(arr ,arr ,arr)的问题 - let args=[...new Set(arguments)]; - //this -> Set - let unique=new Set(this); - //展开参数数组,并再次去除所有重复元素(concat(arr)和push(...arr)好像差不多) - let all=Array.from( - new Set( - args.reduce((previous,current)=>previous.concat(current)) - ) - ) - //与this去重 - .filter(v=>!unique.has(v)); - //添加元素 - this.push(...all); + for(const arr of arguments){ + for(const item of arr) this.add(item); } return this; }