let a = [1,2,2,3] let b = [2,2] // 要求返回[2, 2] function union(a,b){ return a.filter(val => { return b.indexOf(val) > -1 }) } console.log(union(a,b))