JavaScript中将数组进行合并的基本方法讲解
这里简单地讲两种方法:
第一种
varmergeTo=[4,5,6], mergeFrom=[7,8,9]; mergeTo=mergeTo.concat(mergeFrom); mergeTo;//is:[4,5,6,7,8,9]
or
vara=[1,2],b=[3,4],c=a.concat(b);
第二种
varmergeTo=[4,5,6], varmergeFrom=[7,8,9]; Array.prototype.push.apply(mergeTo,mergeFrom); mergeTo;//is:[4,5,6,7,8,9]
合并多个数组mergearray:
//特殊处理业务-必须启用 var_SPECIAL_MUST_ENABLE_LIST=['intime']; if(termNo!=null&&termNo.indexOf("9966")==0){ varnewMustEnableList=['mobile','psp','jtk','credit','train','bank','alipay','lottery','movie','littleTransfer', 'trafficFines','concert','mall','airplane','hotel','recycle']; _SPECIAL_MUST_ENABLE_LIST=_SPECIAL_MUST_ENABLE_LIST.concat(newMustEnableList); }