From 493266d0c389b377d52aa5606bb1cbd1f633e2e5 Mon Sep 17 00:00:00 2001 From: shijian <2954700422@qq.com> Date: Wed, 11 Oct 2023 09:55:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E6=BB=9Aaddarray?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/game.js | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) 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; }