We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
javascript数组去重,数组交叉对比 demo:http://jsbin.com/wofupuyiqe/edit?js,console,output
var arr1 = [1,2,3,4,5,34,34,4,5456,56,45,'happt','end'] var arr2 = [2,3,88,44,'end'] var results = [] arr1.map((data, i) => { arr2.map((datas, j) => { if(data === datas) { results.push(data) } }) }) // 数组交叉对比,arr1内遍历arr2对比 console.log(results) var arr3 = [1,2,3,4,65,4,3,32,3,4,5,3,3,2,5,435,45,45,4] var arr4 = [] arr3.map((data, i) => { if(arr4.indexOf(data) === -1) { arr4.push(data) } }) // indexOf判断空数组arr4内是否存在元素,不存在就反回-1,把元素推进空数组arr4 console.log(arr4)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
javascript数组去重,数组交叉对比
demo:http://jsbin.com/wofupuyiqe/edit?js,console,output
The text was updated successfully, but these errors were encountered: