DEV Community

Discussion on: Is reduce() bad?

Collapse
 
miketalbot profile image
Mike Talbot ⭐ • Edited

Just to say in the example you give, this would be faster than all of those indexOf calls!

function intersection(...params) {
    return Array.from(new Set(params.flat(Infinity)))
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
sorgloomer profile image
Tamás Hegedűs

That's not an intersection, that's a union.