const arrSync = [30, 20, 50, 20, 30]
//数组去重
const newArrSync = arrSync.filter((ele, index, arr) => arr.indexOf(ele) == index)
const arr = [
{text: '新建10', value: 10},
{text: '新建20', value: 20},
{text: '新建30', value: 30},
{text: '新建40', value: 40},
{text: '新建50', value: 50},
{text: '新建60', value: 60}
]
let aa = []
arrSync.map(item => {
aa.push(arr.filter(items => items.value == item)[0])
return item
})
// console.log(aa)
function newArr (newArrs = [], arrs = []) {
let arr = []
newArrs.filter((item, index, arr) => arr.indexOf(item) === index)
newArrs.map(item => {
arr.push(arrs.filter(items => items.value == item)[0])
return item
})
return arr
}
console.log(newArr(arrSync, arr))
网友评论