获得徽章 13
- 数组对象属性值去重
let temp = [ { "text": "单线", "color" : "" }, { "text": "多线", "color" : "" }, { "text": "单线", "color" : "" }, { "text": "@三分", "color" : "" } ];
操作之后,只要:单线多三分
自己是这么写的,可以优化下吗
const strTemp = temp.map(item => item.text) .reduce((pre,cur) =>{ return pre.concat(cur)}) const strArr = [...strTemp] const strTempArr = strArr.filter(it => reg.test(it)) const str = [...new Set(strTempArr)].join("")展开赞过131